1

I am trying to find out how to search some rows with a specific tag contained in a StringSet in AWS DynamoDB with the AWS SDK v2 for iOS.

I couldn't find anything for doing this in the official Amazon iOS documentation for DynamoDB, so I tried this expression but it doesn't work:

let queryExpression = AWSDynamoDBQueryExpression()
queryExpression.limit = 300
queryExpression.filterExpression = "tags CONTAINS :tag"
queryExpression.expressionAttributeValues = [":tag": self.searchQueryTag]

Global.appDelegate().dynamoDBObjectMapper.query(BlogPost.self, expression: queryExpression)
    .continueWithBlock({(task: AWSTask) -> AnyObject? in

    if (task.exception != nil || task.error != nil)
    {
        completion(response: 0)
    }
    else if ((task.result) != nil)
    {
        if(task.result!.count > 0)
        {
            // LIST ALL IDS…
        }
        else
        {
            completion(response: 0)
        }
    }

    return nil
})

Can somebody teach me how to query as specific string in StringSets (NSSets) in DynamoDB by using the AWS iOS SDK?

1 Answer 1

5

Change this line

queryExpression.filterExpression = "tags CONTAINS :tag"

to this

queryExpression.filterExpression = "contains(tags,:tag)"

Sign up to request clarification or add additional context in comments.

1 Comment

Wow this was hard to find this answer, great job!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.