On Wednesday, April 16, 2014 9:31:23 AM UTC-7, Johnny Caveman wrote:
>
> Hello everyone, I'm new to couchbase lite and a little confused the 
> mechanism of groupLevel. 
>
> Let's say if after map process, the document's key is an date-type-color 
> array, and value is some concrete value need to be aggregated, how to write 
> a REDUCEBLOCK equivalent to *_count*, which allows you to drill down when 
> aggregating associated with groupLevel. Just like 
> this<http://blog.couchbase.com/understanding-grouplevel-view-queries-compound-keys>
> .
>
>
Group level works just the same in Couchbase Lite as it does in Couchbase 
Server or Apache CouchDB. What makes it hard to grasp for many people is 
it's simplicity...

So if you have [date, type, color] as a key structure, you can get a count 
of all items in a date range, or all items of a given type on a particular 
date (Assuming you aren't including hours in the date), or a count of the 
number of red trucks on that date.

If you want to count all red items or all with type=truck, you'll need an 
index with keys in a different order, maybe [type, color] or [color, type] 
depending on your app.

Hope that helps!

-- 
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/3ce18ea8-68ab-437b-b4cb-00734ab4eb17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to