0

I have the following array:

array(3) { [0]=> string(8) "xp is 20" [1]=> string(19) "level between 9, 50" [2]=> string(20) "cars between 100,200" } 

First is field than is operator and after is the value searched for. My view is as follows:

function (doc) { emit([doc.data.xp, doc.data.level, doc.data.cars]) }

Basically I want to search for key xp equal to 20 AND level between 9 AND 50 AND cars BETWEEN 100 AND 200.

Can I do that in Couchbase and if so, how?

Gabriel
  • 772
  • 1
  • 13
  • 37

1 Answers1

1

No, you can't do that, at least now. Couchbase view has only one index, so you can have only one "between" per view.

But you can create 2 views that will emit "xp equal to 20 AND level between 9 AND 50" and "xp equal to 20 AND cars BETWEEN 100 AND 200" and then intersect result arrays on app-side. For more info about composite keys view this question.

Community
  • 1
  • 1
m03geek
  • 2,508
  • 1
  • 21
  • 41
  • Is the only solution to use elasticsearch if you want to use couchbase and your backing store but need to retrieve docs based on more than one index? – Michael Nov 20 '13 at 17:20
  • Yes, elasticsearch would be the best option for this. – m03geek Nov 20 '13 at 23:05