- Newest
- Most votes
- Most comments
Create a GSI where the PK is Country+Location concatenated and the SK is the last_updated. Then for any given Country+Location value you can find the last updated values (and corresponding customer ids in the projection) for that location. Note you can setup 20 GSIs.
Or are you hoping to do a begins_with against the location (like for the wider value of WA:King) while also getting only the latest X many? In which case, well, you can't. You can however insert new items for each hierarchical level (like WA:King, etc) so that that value can be used as the PK. Basically pre-materialize at each level. You only get one sort key per table/index and you can't use the sort key functionality twice.
Of course, if you intend to get ALL the matching items (not just the latest X many) and just want them sorted, you can sort on the client.
Relevant content
- Accepted Answerasked a year ago
- asked 2 years ago
- asked 5 years ago
- AWS OFFICIALUpdated 25 days ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated 7 months ago
Thanks! I was indeed hoping to do something like a
begins_with
, so it looks like I'm a little out of luck. I think what I'm going to do is create a different GSI for each potential level of hierarchy (e.g. one for Country, one for State, etc.) with the location as the PK andlast_updated
as the SK, and query the appropriate GSI based on the level of hierarchy needed.