Partial Selection - StartKey and EndKey

As explained in

I am planning to subset the results of a view by Partial selection using StartKey and EndKey

For instance to find all nodes which have almond*, I plan to do the following

        var client = CouchbaseManager.Instance;
        var view = client.GetView("nuts", "nutsonly");
        string searchKey = "almond"
        view.EndKey(searchKey + "\u02ad");

Is this kind of queries using wildkey - encouraged or discouraged - especially from a performance point of view ?

If this is discouraged, then I need to some how find all the nodes with Almond* as its key. Which other approach do you recommend.


What you are doing is correct, and this is why the views have been designed for.

The only commend that I will do is usually with Couchbase we use in range query\uefff that is the last unicode character.

If you look at the beer sample application you will see that this is how we deal with such requirements. Here for example the Java code that look for all the "Breweries with a name starting by ":


If you want to limit the view query to only return those indexes which have ‘nuts’ and not ‘nutsonly’, how would you go about this? I initially thought:


might do the trick but that results in no matches. My guess was the very FIRST unicode character might be the recommended solution?

 view.EndKey("nuts" + "\u0000); 

But getting a non-visible character into the Couchbase admin app was a pain so now I’m wondering if maybe 0020 (aka, a space, the first visible character) is a reasonable alternative?

The view functionality for the admin console is fairly basic. If you think this might be helpful, I suggest you file a bug to add an option to “handily” insert such a character into your JSON.

Space could work as an alternative but is probably not “Correct”.