2

I'm fairly new to NoSQL. Using Python/Boto but this is a fairly general question. Currently trying to switch a project from MongoDB to DynamoDB and seeking some advice on DynamoDB and it's capacity to query if a list contains a certain string. I have been searching for the past day or so but I'm starting to worry that it doesn't have this facility, other than to use scan which is terribly slow considering the db will be queries thousands of times on updates. Similar unanswered question here

I understand primary keys can only be N, S or B and not something like String Set (SS) which would have been useful.

The data is fairly simple and would look something like this. I'm looking for the most efficient way to query the db based on the tag attribute for entries that include 'string1' OR 'string2'. Again, I don't want to use scan but am willing to consider normalization of the data structure if there is a best practice in dynamodb.

{
   id: <some number used as a primary key>,
   tags: ['string1', 'string2'...],
   data: {some JSON object}
}

From what I've read, even using global secondary indexes, this doesn't seem possible which is strange since that would make dynamodb only useful for the most simple queries. Hoping I'm missing something.

2
  • Are you saying you have only tags data to query the data and you dont have partition key as well? Commented Apr 17, 2017 at 6:27
  • The id key will be the partition key and just some kind of auto increment at that. Dynamodb only allows two primary keys I believe, a hash and range (which is optional). I could include a secondary string key but unless that can be a list or set with a variable number of tags in it, then it won't be useful for querying. For context, the JSON object is a collection of social media updates and the tags are the keywords that relate to it. Commented Apr 17, 2017 at 6:38

1 Answer 1

2

In MongoDB, you have multikey indices, but not in DynamoDB.

I'd think you'd need to solve it like you would in a relational database: create a many-to-many relation table with tag as your hash key and entry id as your sort key. And find some way to keep your relation table in sync with your entry table.

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

1 Comment

I see, which defeats the purpose slightly of using a NoSQL database. Sadly I've decided to switch back to Mongo. Not being able to store indexes on document items is just too much of a limitation.

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.