Posted under CouchDB
Permalink
Here is an example of a range query. The keys are arrayed, of the form
[postTown, locality, name, id, 0] for the place document, and:-
[postTown, locality, name, id, 1] for the immediately following placeFeatures document.
(Assuming ?include_docs=true is used to include the documents)
Here is one with the same start and end keys:-
Note that in this case, we have had to append the null object as the next element in the key, or the query would return nothing at all. This works because the null object comes last in the collation sequence, i.e. after all possible values for the name element of the key, so this allows all places for Neatishead to be included.
The opposite of this is “”, the empty string (or a null), both of which come first in the collation sequence.
The trick is documented in this Stack Overflow post here
Leave a Reply
You must be logged in to post a comment.