I'm trying to use a Scan operation on a DynamoDB table to match items with given 'tags'. The tags for an item are stored in a single set attribute. E.g.:
machine-1: tags = "windows", "iis", "64bit" machine-2: tags = "windows", "fs"
Now, I have a support case open with Premium Support, but it's taking some amount of time. What I want to do is match machines where 'tags' contains the entry "windows" and "iis".
I can match a single one by using the CONTAINS
mode, and specifying a single AttributeValue with a string value of "windows", for example.
However, CONTAINS
does not support sets in a single AttributeValue, or multiple AttributeValues. It gives an error.
So I tried IN
(something AWS premium support also suggested): however, whether I use a single AttributeValue (even just looking for "windows" again or multiple ones), I get zero results.
The documentation for IN
is pretty poor. The operation is described in 4 uninformative words, in fact: "checks for exact matches".
While I wait for support possibly going on with a few more rounds of Q&A, is anyone reading this familiar with this kind of query with Scan? (If you could, please test what you're saying in your answer first: I think I have tried the obvious ones!)
For ref, Scan documentation: http://docs.amazonwebservices.com/amazondynamodb/latest/developerguide/API_Scan.html
Yes, like all the other database management systems, DynamoDB also supports all the conditional operators, User can specify a condition that is satisfied for a put, update, or delete operation to work on an item.
For faster response times, design your tables and indexes so that your applications can use Query instead of Scan . (For tables, you can also consider using the GetItem and BatchGetItem APIs.) Alternatively, design your application to use Scan operations in a way that minimizes the impact on your request rate.
DynamoDB supports the Java Set , List , and Map collection types. The following table summarizes how these Java types map to the DynamoDB types. BOOL (Boolean type), 0 or 1. S (string type).
This from AWS premium support:
"Hello.
I got confirmation from Dynamo DB this is currently not supported. CONTAINS against a set can only be performed with a single value. "
Urgh. So now I will create a new attribute for each possible tag, with a 'True' or 'False' in each column, and filter my Scan on that.
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