Hi there,

On 27/05/11 16:01, Gabor Ratky wrote:
The order of your components of your keys matter. There is no way to ignore the 
first element of your key. You should instead reorder your keys based on what 
you're trying to count / query.

emit([created_at, a_name, one_id, another_id]);

and querying with:

?group=true&group_level=2&startkey=["2011-05-26"]&endkey=["2011-05-27", {}]

results in:

{
  "key": ["2011-05-26", "Lisa"],
  "value": 1
},
{
  "key": ["2011-05-26", "John"],
  "value": 2
},
{
  "key": ["2011-05-27", "John"],
  "value": 1
}

You can of course emit not just days, but also weeks, months, quarters if 
that's what you always want. If it arbitrary and you need to aggregate the 
names afterwards from this smaller set, yo should do it in the client (whoever 
calls CouchDB to get this information out).

Mhmm, ok, thanks for explaining this.

It means though, that for every unique time stamp that a_name has an entry, there will be a corresponding count returned (like the three you listed above).

Hence, if a_name has 1000 entries at slightly different times within the time range I'm searching for (my created_at includes seconds), I will get 1000 such entries back.

tldr; The elements and order of the keys determines the order of the index and 
you can only filter for a contiguous part of that index with startkey / endkey.

Ok, thanks a lot for your confirmation!

Cheers,

-Torstein


Reply via email to