0

I Have a map function

function (doc, meta) {
  emit([doc.Marks,doc.Acc_no],doc.Type);
}

In this when I send startkey and endkey as follows

startkey = [13]
endkey   = [86]

I get all the documents having marks between 13 and 86 as expected irrespective of Acc_No.

Now what I am trying is a query like this

 startkey =[,1]
 endkey =  [,5]

That is I want all documents having Acc_no between 1 and 5 irrespective of their Marks but I am getting error in this type of query. How can I accomplish my second type of query without making a new view?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Legendary_Hunter
  • 1,040
  • 2
  • 10
  • 29

1 Answers1

3

No, you can't do that. If you create a key, as an array here, you should use the "first N", you can skip the last objects in the array, but you must specify them from start to some point. So you can skip only from the right, not from the left.

To achieve your goal here you have 2 choices:

  1. write a different view without the marks.
  2. think of a better sequencing of your key that will suit you the best.

For more information, refer to the documentations.

http://docs.couchbase.com/admin/admin/Views/views-querying.html

Roi Katz
  • 575
  • 4
  • 14
  • Its been long time since this question but I have 1 more doubt regarding skipping parameters. Can we also skip right side parameters while querying? It seems like I am not able to do it. – Legendary_Hunter Mar 10 '16 at 07:24
  • What do you mean by not able to do it? just don't add the right hand parameters. do you have an example? – Roi Katz Mar 10 '16 at 07:29
  • Yes. Didnt got an answer so I thought asking here too. Please help on any post :P – Legendary_Hunter Mar 10 '16 at 08:37