view filtering
Hi,
I have a key in view like [int, string] and I need filter by two ways:
1) only by first part of key, in this case I put to startkey = [value, "\u0000"] and put to endkey = [value, "\u0fff"]. works correct and fine.
2) only by second part of key, in this case I need to filter like previous one point but vise versa . startkey = ["\u0000",value] and put to endkey = ["\u0fff",value]. But always no data after apply filter like this.
Can I filter view only by second part of key and ignore first part?
thanks.
joakimw, very thanks.
Hello,
In addition to Joachim answer let me point you to some interesting blog post about keys and ordering:
- http://blog.couchbase.com/understanding-letter-ordering-view-queries
- http://blog.couchbase.com/understanding-grouplevel-view-queries-compound...
It is not a direct answer to your question but it is interesting to have these pointer in this discussion.
regards
No, you can't filter on the second part only.
Indexes must be sorted somehow, and they are sorted by the first element first, then the second.
So a search on the second part would have to traverse the whole list of keys to find your matches. Couchbase doesn't do this (some other DB's do this, it's called a "key scan" and is really slow).
You have to create a second index using [string, int] instead and search on that.