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 22:16:51 GMT
the + sign has to be encoded too, at least I did that on my test db to
get it to work

On Tue, Oct 19, 2010 at 10:31 AM, Lee Nelson <lnelson@nelnet.org> wrote:
> I'm clearly doing something wrong, I just can't figure out what.  I
> get different results from what it's suggested I should see.  CouchDB
> sees this query:
> [info] [<0.26537.9>] 10.0.1.8 - - 'GET'
> /netelligence/_design/telemetry/_view/usage_dates?startkey=%222010/10/15%2021:20:00%20+0000%22&endkey=%222010/10/15%2021:25:00%20+0000%22&inclusive_end=true
> 200
>
> And gives me a result of one row:
> {"total_rows":1070,"offset":1,"rows":[
> {"id":"9856cb1e-4990-2a91-8507-f6abb266093c","key":"2010/10/15
> 21:20:00 +0000","value":null}
> ]}
>
> What I'm really looking for is to be able to query a single value but
> the query returns nothing.
>
>
>
>
> On Mon, Oct 18, 2010 at 5: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