I want to use regex when I query a table. I tried to use it under KeyConditionExpression
, but it isn't valid. Is there any way to do it with DynamoDB?
For example, my primary key is a string, and I want to get all the items that start with an A
. The KeyConditionExpression
expression would look like "someKey = /^A/"
Querying is a very powerful operation in DynamoDB. It allows you to select multiple Items that have the same partition ("HASH") key but different sort ("RANGE") keys.
The Query operation allows you to limit the number of items that it reads. To do this, set the Limit parameter to the maximum number of items that you want. For example, suppose that you Query a table, with a Limit value of 6 , and without a filter expression.
More complex queries on DynamoDB data are occasionally required. Instead of scanning for such queries, it is usually preferable to create a GSI (global secondary index). Out of interest, I ran an experiment to confirm that Scan operation is indeed slower than Query operation.
DynamoDB does support the complex condition on FilterExpression . Perfectly fine.
No. DynamoDB does not support regex.
The closest thing is CONTAINS
and NOT_CONTAINS
.
See documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With