Juarez Junior
Juarez Junior

Reputation: 13

DynamoDB get items with an attribute that is a substring of a value

I'm trying to query items in DynamoDB checking if one of their attributes is a substring of a provided value.

So basically, I am trying to do a query using something similar to contains(attribute_name, :input_value) but like this instead: contains(:input_value, attribute_name) (check if the attribute is inside the input value)

Ex: If my items have the following attributes:

---------------------
 item_id |  domain
---------------------
1        | amazon.com
---------------------
2        | amazon.com
---------------------
3        | google.com
---------------------

And I use 'https://us-east-1.console.aws.amazon.com/' as input I want the 2 first items to be returned from the query.

Is there a way to make something like this in DynamoDB?

Upvotes: 0

Views: 169

Answers (1)

Leeroy Hannigan
Leeroy Hannigan

Reputation: 19683

No, you cannot do a substring match in reverse. Before making the request to DynamoDB you should remove only the domain portion from the string as thats what you want to evaluate on.

Upvotes: 1

Related Questions