I'm having access on a CouchDB view wich emits documents having keys of two arrays of four integers like [[int, int, int, int], [int, int, int, int]]
. In a concrete example those correspond to start-date and end-date of the document:
[[2017, 5, 5, 10], [2017, 7, 2, 11]]
Y m d H Y m d H
I'm able to get documents matching a period
request="localhorst/dbname/_design/a/_view/period"
request+="?key=\[\[2017,5,5,10\],\[2017,7,2,11\]\]"
curl -sX GET $request
Question: How to ignore the "hour" field H?
What if the boundaries are partially unknown? How to get all documents within a given period, like 2017-05-05
until 2017-07-02
? In other words, how can I ignore the last columns of each boundary?
I tried to use startKey
and endKey
request="localhorst/dbname/_design/a/_view/period"
request+="?startKey=\[\[2017,5,5\],\[2017,7,2\]\]"
request+="&endKey=\[\[2017,5,5,\{\}\],\[2017,7,2,\{\}\]\]"
curl -sX GET $request
This does not work since it gets documents with the correct lower bound but the upper bound is wrong, e.g.:
[[2017,4,5,10],[2017,7,2,12]] <- excluded, OK
[[2017,5,5,10],[2017,7,2,12]] <- contained, OK
[[2017,5,5,11],[2017,7,2,12]] <- contained, OK
[[2017,5,5,10],[2017,8,2,12]] <- contained, ERROR