couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From couchdb user <couchdbu...@gmail.com>
Subject Re: Query by specific date vs range
Date Tue, 19 Oct 2010 03:52:36 GMT
Hi Lee,

You will need to url encode your key, for example:

2010/10/17 06:35:00 +0000

is

2010/10/17%2006:35:00%20%2B0000

I tested and

http://127.0.0.1:5984/couch/_design/exampleView/_view/dates?key=%222010/10/17%2006:35:00%20%2B0000%22

gave me the row I was looking for



Regards,




On Mon, Oct 18, 2010 at 7:45 PM, Paul Davis <paul.joseph.davis@gmail.com> wrote:
> The "key" URL parameter is in effect doing this:
>
> start_key=$(key)&end_key=$(key)
>
> View selection is about sorting. By default, it returns everything
> start_key <= row_key < end_key. If you add inclusive_end=true to your
> query, it'll change the comparison operators to: start_key <= row_key
> <= end_key.
>
> HTH,
> Paul Davis
>
> On Mon, Oct 18, 2010 at 7:29 PM, Lee Nelson <lnelson@nelnet.org> wrote:
>> When I query using a date range (startkey and endkey) I get a
>> response, however when I query by a single date (key=), I get no
>> response.  Examples:
>>
>> http://10.0.1.136:5984/netelligence/_design/telemetry/_view/usage_dates?key="2010/10/15
>> 21:20:00 +0000"
>> Returns:
>> {"total_rows":886,"offset":1,"rows":[]}
>>
>> However:
>> http://10.0.1.136:5984/netelligence/_design/telemetry/_view/usage_dates?startkey="2010/10/15
>> 20:15:00 +0000"&endkey="2010/10/15 21:20:00 +0000"
>> Returns:
>> {"total_rows":888,"offset":0,"rows":[
>> {"id":"7963df3f-a271-8da4-3b66-c5a0ed16d0bd","key":"2010/10/15
>> 21:15:00 +0000","value":null}
>> ]}
>>
>> I'm also perplexed by the fact that the range query only returns one
>> row when there are entries at 21:15 and 21:20.  Why, when I query by
>> "key" do I get nothing and when I query by start- and endkey, do I
>> only get one of the two values in the range?  I've been banging my
>> head against this for two days.
>>
>> My map function:
>> function(doc) {
>>    if(doc.sampletime) {
>>        emit(doc.sampletime, null);
>>    }
>> }
>>
>> There is no reduce function.
>>
>> Here's an example document:
>> {
>>   "_id": "ff41b06d-d19c-0275-abac-a38798e9bdbe",
>>   "_rev": "1-3986507576f0da9fd5be20fd88724df1",
>>   "category": "telemetry",
>>   "type": "usage",
>>   "measurement": "bandwidth",
>>   "device": "rtr02-frfd",
>>   "sampletime": "2010/10/17 06:35:00 +0000",
>>   "ports": [
>>       {
>>           "Gi8/36": [
>>               {
>>                   "InOctets": 0,
>>                   "InUcastPkts": 0,
>>                   "InMcastPkts": 0,
>>                   "InBcastPkts": 0,
>>                   "OutOctets": 0,
>>                   "OutUcastPkts": 0,
>>                   "OutMcastPkts": 0,
>>                   "OutBcastPkts": 0
>>               }
>>           ],
>>           "Gi4/0/5": [
>>               {
>>                   "InOctets": 0,
>>                   "InUcastPkts": 0,
>>                   "InMcastPkts": 0,
>>                   "InBcastPkts": 0,
>>                   "OutOctets": 0,
>>                   "OutUcastPkts": 0,
>>                   "OutMcastPkts": 0,
>>                   "OutBcastPkts": 0
>>               }
>>           ]
>>       }
>>   ]
>> }
>>
>

Mime
View raw message