Gabriel
Gabriel

Reputation: 792

Couchbase composite keys search

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?

Upvotes: 0

Views: 292

Answers (1)

m03geek
m03geek

Reputation: 2538

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.

Upvotes: 1

Related Questions