I think we can get away with a postFilter, as the key will be an array, and 
the first item must be an exact match which should greatly limit the 
results.

Sorry, one more question. If I understand correctly, the postFilter step is 
done after any reduce, correct? So it can't be used to filter rows before 
counting them in a reduce? I would simply have to specify mapOnly = true 
and count the rows in the result myself?

Thanks so much for your help.

Kevin

On Tuesday, February 3, 2015 at 12:54:39 PM UTC-4, Jens Alfke wrote:
>
>
> On Feb 3, 2015, at 5:56 AM, Kevin Lord <[email protected] <javascript:>> 
> 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/6999b6ca-1aa1-456a-a8c4-70952ea756f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to