couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: How to query multi item key
Date Tue, 08 Sep 2009 18:34:19 GMT
> {"key":["27.0.0.1","2009/08/12 18:37:06 +0000"],"value":null},
> {"key":["12.0.0.1","2009/08/13 02:29:57 +0000"],"value":null},
> {"key":["17.0.0.1","2009/08/14 21:25:27 +0000"],"value":null},
> {"key":["31.0.0.1","2009/08/15 02:54:03 +0000"],"value":null},
> {"key":["11.0.0.1","2009/08/16 08:35:15 +0000"],"value":null},
> {"key":["12.0.0.1","2009/08/17 19:21:59 +0000"],"value":null}
>
> If I want all of the IP's in a given date range (2009/08/13 - 2009/08/16)
> what is the right way to construct the query?  The hang-up is trying to
> figure out the right value for the first item in the key to act as a '*'

That's because you can't. The answer is to swap the order of your emit, thus:

emit([doc.ip, doc.date], null) -> emit([doc.date, doc.ip], null)

And then use:

http://localhost:5984/foo/_design/test/_view/by_ip_and_created_at?startkey=["2009/08/13",
null]&endkey=["2009/08/16", {}]

HTH,
Paul Davis

Mime
View raw message