> On Feb 3, 2015, at 5:56 AM, Kevin Lord <[email protected]> wrote:
> 
> Thanks Jens, that makes sense.
> 
> what if I wanted to match on a partial first name or last name? Say I've 
> broken the name up as much as I can beforehand, and emitted the multiple 
> keys, but I'd like to get all results that start with "Jon" including both 
> "Jon" and "Jonathan".

You can do that with a prefix match. The standard idiom is to set 
startKey="Jon" and endKey="Jon\uFFFE" (or appending any other very large 
character value.) I was going to recommend the newish prefixLevel property 
that's available in iOS, but my colleague Pasin just found out it isn't working 
correctly in 1.0.3.

> Also, potentially more difficult, I'd like to match the ending of an 
> individual name component? Would I need to move to the postFilter predicate 
> for this? 

The only fast way I can think of matching by ending is to emit the reversed 
name, and query on reversed keys.

Of course, these optimizations may not even be necessary. It depends on how 
many names there are likely to be in the database and how quickly you need the 
query to run. If this is some kind of personal address book, for example, with 
a couple of hundred names at most, it probably won't make any noticeable 
difference either way.

> P.S. - Just a heads up. It seems the main documentation on the Couchbase 
> Mobile site is a bit out of date. Had to check the docs on Github to find 
> postFilter.

The main docs only cover features that are available cross-platform; new 
feature that aren't yet available on all platforms usually get documented in 
the Github wikis.

—Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/6D39365C-39ED-41E3-BE04-78AC6AC38734%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to