Thank you for taking the time in reading my question.
My scenario is this. I have a geopoints table in dynamodb.
It consists of:
object_type(String HASH)
id(String RANGE)
lat(Number GSI RANGE)
lng(Number GSI RANGE)
It has indexes of:
object_type-lat-index(object_type-hash lat-range)
object_type-lng-index(object_type-hash lng-range)
What I want to do:IndexName: "object_type-lat-index",
KeyConditionExpression: "object_type=:otype AND (lat BETWEEN :llat AND :glat) AND (lng BETWEEN :llng AND :glng)",
I want to be able to query lat and lng by getting the betweens of a least lat and greater lat, and least lng and greater lng
I can't seem to find it in the dynamodb docs. Can this be done or am I implementing it correctly? Because the error is returning something like 'Can only have 1 or 2 conditions'
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html#GSI.Querying
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/QueryAndScan.html
The way it works is the query works against the table itself (the keys defined in the table) or a GSI. You cannot combine multiple GSIs and the table HK in the same query.
2 options here:
1) perform 2 queries against the 2 indexes and intersect the results on the client
2) do one 1 query against one of the indexes w/ a filter expression that works with the other expression (so basically, for example: query on lat with a filter for long).
You can create a new attribute in the table that has a combination of several attributes and create a secondary index for that new attribute, in this way, you can search for several parameters using KeyConditionExpression.
but if you need to search for coinside (contain), this is not the way
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