开发者

search with startkey, endkey and array keys

开发者 https://www.devze.com 2023-01-05 02:34 出处:网络
I have a view wich returns several elements with array keys. Example : {\"total_rows\":4,\"offset\":0,\"rows\":[

I have a view wich returns several elements with array keys.

Example :

{"total_rows":4,"offset":0,"rows":[
    {"id":"","key":[15,"2"],"value":1,"doc":{},
    {"id":"","key":[20,"2"],"value":1,"doc":{},
    {"id":"","key":[20,"3"],"value":1,"doc":{},
    {"id":"","key":[20,"4"],"value":1,"doc":{}
]}

I'm trying to search through those elements. So if I do the following request :

/datab开发者_如何转开发ase/_design/element/_view/all/?
  startkey=[15, "2"]&
  endkey=[20, "3"]&
  include_docs=true&reduce=false

Live example : http://jchris.couchone.com/keyhuh/_design/Record/_view/by_CreationDate_and_BoreholeName?startkey=[1267686720,%22sp4%22]&endkey=[1267686725,%22sp4\u9999%22]&include_docs=true&reduce=false

This one doesn't works. It returns me all the records, even the last one, which doesn't meets the second element of the array.

Strangely enough, it works with strings only.

Example :

{"total_rows":4,"offset":0,"rows":[
    {"id":"","key":["15","2"],"value":1,"doc":{},
    {"id":"","key":["20","2"],"value":1,"doc":{},
    {"id":"","key":["20","3"],"value":1,"doc":{},
    {"id":"","key":["20","4"],"value":1,"doc":{}
]}

if I do the following request :

/database/_design/element/_view/all/?
  startkey=["15", "2"]&
  endkey=["20", "3"]&
  include_docs=true&
  reduce=false

Live Example : http://jchris.couchone.com/keyhuh/_design/Record/_view/by_Client_and_BoreholeName?startkey=[%22Test1%22,%22sp4%22]&endkey=[%22Test1%22,%22sp4\u9999%22]&include_docs=true&reduce=false

Here it'll work well and only return the three first elements.

Am I missing something with couchdb's search for arrays with integers and strings ? Or have I fallen on a bug ?

Note : it does the same with CouchDB 0.10 and 0.11.


This looks wrong, and there are a few things it could be. Is it possible for you to share your code with us? If the data isn't proprietary you could replicate your db to http://jchris.couchone.com/keyhuh and I'll take a look at the whole thing there.

...

Thanks for posting the live data. This is the query that is busted?

http://jchris.couchone.com/keyhuh/_design/Record/_view/by_Client_and_BoreholeName?startkey=[%22Test1%22,%22sp4%22]&endkey=[%22Test1%22,%22sp4\u9999%22]&reduce=false

Because that looks fine to me. What am I missing?

0

精彩评论

暂无评论...
验证码 换一张
取 消