DynamoDB Scan with filter, matching 'is-in-set' conditions
Asked Answered
A

1

14

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

Appropriate answered 5/7, 2012 at 7:35 Comment(1)
When I get a response (well, a good one: no good so far) from premium support I will post it here. Taking a long time, but they're contacting the developers directly now..Appropriate
A
11

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.

Appropriate answered 10/7, 2012 at 9:38 Comment(1)
you could have done "tags contains windows or tags contains iis"Wetzell

© 2022 - 2024 — McMap. All rights reserved.