2

I created a view with two fields as key for the index like this [type, time]. When I tried to fetch the documents using the below query I was missing some of my documents in the resultset.

Javascript view I used looks something like this:

function(doc,meta) { 
   if(doc.name==type_1)
     emit([type_1,doc.time],doc);
   else if(doc.name==type_2) 
     emit([type_2,doc.time],doc);
 }

here type_1 and type_2 are document types mentioned above

Query I used:

URL/VIEW_PATH?stale=update_after&inclusive_end=true&connection_timeout=60000&limit=10&skip=0&startkey=[type,start_time]&endkey=[type,end_time]&full_set=true

I had one document which should be there in the result. But I didn't get any.

Am I doing something wrong here?

Couchbase Version: 3.1.6-1904 Enterprise Edition (build-1904)

Number of documents in my bucket ~5M

Mohit
  • 79
  • 2
  • 6
  • Your query limits the number of documents to 10, did you get less than 10 documents? – uminder Dec 11 '19 at 10:25
  • 2
    Please don't use the `couchdb` tag for things unrelated to CouchDB – Jonathan Hall Dec 11 '19 at 12:39
  • @uminder I have one document which should be there in the result. But I didn't get any. So this was not the issue for sure – Mohit Dec 11 '19 at 13:52
  • Would you please post the javascript view code? – Matthew Groves Dec 11 '19 at 14:17
  • @MatthewGroves It looks something like this: `function(doc,meta) { if(doc.name==type_1) emit([type_1,doc.time],doc); else if(doc.name==type_2) emit([type_2,doc.time],doc);}` here type_1 and type_2 are document types I mentioned in the question – Mohit Dec 12 '19 at 04:24
  • Are type_1 and type_2 supposed to be strings? E.g. should it be `doc.name=="type_2"`? Also, could you post the one document that you expect to be in the result? – Matthew Groves Dec 12 '19 at 14:15
  • @MatthewGroves yes, I'm using quotes around my document type. `{ "name": "userJob", "data":SOME_VALUE, "time": "1576045481" }` This is a sample doc I'm expecting in the result – Mohit Dec 13 '19 at 06:17

0 Answers0