我有一个返回以下数据的视图:
https://domain/db/_design/designdoc/_view/view
{"total_rows":3,"offset":0,"rows":[
{"id":"test1","key":[2015,2,18,1,33,27],"value":null},
{"id":"test3","key":[2015,2,20,1,33,27],"value":null},
{"id":"test2","key":[2016,2,19,1,33,27],"value":null}
]}
查询特定密钥有效,例如:
https://domain/db/_design/designdoc/_view/view?key=[2015,2,20,1,33,27]
{"total_rows":3,"offset":2,"rows":[
{"id":"test3","key":[2015,2,20,1,33,27],"value":null}
]}
但是,查询范围始终会返回所有三个"行"。我做错了什么?
https://domain/db/_design/designdoc/_view/view?startKey=[2015,2,20,1,33,27]
{"total_rows":3,"offset":0,"rows":[
{"id":"test1","key":[2015,2,18,1,33,27],"value":null},
{"id":"test3","key":[2015,2,20,1,33,27],"value":null},
{"id":"test2","key":[2016,2,19,1,33,27],"value":null}
]}
另一个例子:
https://domain/db/_design/designdoc/_view/view?startKey=[2015,2,18,1,33,27]&endKey=[2015,2,20,1,33,27]
{"total_rows":3,"offset":0,"rows":[
{"id":"test1","key":[2015,2,18,1,33,27],"value":null},
{"id":"test3","key":[2015,2,20,1,33,27],"value":null},
{"id":"test2","key":[2016,2,19,1,33,27],"value":null}
]}
答案 0 :(得分:0)
找到答案。以下作品:
https://domain/db/_design/designdoc/_view/view?startkey=[2015,2,18,1,33,27]&endkey=[2015,2,20,1,33,27]
{"total_rows":3,"offset":1,"rows":[
{"id":"test1","key":[2015,2,18,1,33,27],"value":null},
{"id":"test3","key":[2015,2,20,1,33,27],"value":null}
]}
这个例子和之前的例子有什么区别?在这个例子中,我将查询参数指定为" startkey"和" endkey"。以前我错误地将它们指定为" startKey"和" endKey" (注意大写K)。一个艰难的教训。