couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aroj George <aro...@gmail.com>
Subject Re: filtering on timestamp + aggregation on another field
Date Mon, 14 Mar 2011 16:02:57 GMT
Thanks Kinley. But just emitting the timestamp does not solve the problem
for us.

We want to be able to emit something like,

[India,Mahrashtra,Pune,timestamp]  (where Pune is a city in state
Maharashtra which is in country India)

and then we would like to filter using the timestamp and group by location
on say India as,

*startkey=India,%,%,timestamp1 & endkey=India,%,%,timestamp2 & group_level =
1*

This should give me all results grouped by location India, but filtered out
between the two timestamps.

But ofcourse there is no % filter possible it seems.

A SQL equivalent would be,

select * from table where timestamp > timestamp1 and timestamp < timestamp2
group by country.

What's the right thing to do when faced with such a requirement?

we could do a temp view like below?

if (doc.timestamp > T1 & doc.timestamp < T2) emit(doc.location_path,doc)

But aren't temp views considered bad for performance.

Please do suggest the best way to solve this problem in couchdb.


Rgds,
Aroj


On 14 Mar 2011 18:59, "Kinley Dorji" <kinleyd@gmail.com> wrote:

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message