Filter by a second element of composite key


#1

I have two fields a & b, I have created a view with emit([doc.a, doc.b])

Now I want to search only by field b, how can I do that.

Is there something like Key=[{}, 48] or startKey = [{}, 48], endKey = [{}, 49] ?

I am trying to know if I can serve filtering on [a], [b], [a and b] from a single view, as I require large number of filters and their combinations. So can a single view handle filter combinations?


#2

Can somebody please reply, I am stuck on this problem while trying to decide whether to choose couchbase or not, as I have large number of filter combinations in my queries. Creating a different view for every combination of filter and sort would be very difficult. I tried n1ql, but its performance in developer preview is not as good as the views and I don’t know the GA release date.


#3

This sort of composite key for the results in a view generally work best if the data is heirarchical in nature. Think [country, state, county, city] or [2014, 11, 27, 22, 19].

Sometimes you can emit into different parts of the same view though as a way of filtering. If, however, you’re looking to do a union of two indexes though, that would have to be done at the application client.

Perhaps you can give a more specific example of what your data looks like and we can recommend an approach?


#4

Here is my Sample doc:
{
“id”: 1458975,
“vendorCode”: “3857”,
“uploadId”: “8qnhdjfp5yu8uxbd4fhi”,
“categoryId”: 679,
“submittedOn”: 1416721094384,
“status”: “Incomplete”,
“imageStatus”: “Submitted”,
“assignee”: “klm4ngbdgwe14vfuphx3”,
“updated”: 1416721094384
}

I an looking at filtering on vendorCode, categoryId, uploadId and assignee (in various combinations) and sort on status, imageStatus, submittedOn and updated.