You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Lee Nelson <ln...@nelnet.org> on 2010/10/19 01:29:47 UTC
Query by specific date vs range
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
}
]
}
]
}
Re: Query by specific date vs range
Posted by couchdb user <co...@gmail.com>.
Hi Lee,
Here is a sample session creating a blank database, adding two records
based on what you posted earlier, I create the view you specified and
I query the view by key, see how if I do not encode the + sign, I get
no rows.
This is tested on Fedora 13, using the terminal (Bash)
I hope this helps
On Tue, Oct 19, 2010 at 7:17 PM, Lee Nelson <ln...@nelnet.org> wrote:
> I will try that, but the plus sign is encoded (or not encoded) the
> same whether I'm using "key=" or "startkey= &endkey=". Why would it
> work with startkey/endkey but not with just key?
>
> On Tue, Oct 19, 2010 at 4:16 PM, couchdb user <co...@gmail.com> wrote:
>> 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 <ln...@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 <pa...@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 <ln...@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
>>>>> }
>>>>> ]
>>>>> }
>>>>> ]
>>>>> }
>>>>>
>>>>
>>>
>>
>
Re: Query by specific date vs range
Posted by Lee Nelson <ln...@nelnet.org>.
I will try that, but the plus sign is encoded (or not encoded) the
same whether I'm using "key=" or "startkey= &endkey=". Why would it
work with startkey/endkey but not with just key?
On Tue, Oct 19, 2010 at 4:16 PM, couchdb user <co...@gmail.com> wrote:
> 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 <ln...@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 <pa...@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 <ln...@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
>>>> }
>>>> ]
>>>> }
>>>> ]
>>>> }
>>>>
>>>
>>
>
Re: Query by specific date vs range
Posted by couchdb user <co...@gmail.com>.
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 <ln...@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 <pa...@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 <ln...@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
>>> }
>>> ]
>>> }
>>> ]
>>> }
>>>
>>
>
Re: Query by specific date vs range
Posted by Lee Nelson <ln...@nelnet.org>.
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 <pa...@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 <ln...@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
>> }
>> ]
>> }
>> ]
>> }
>>
>
Re: Query by specific date vs range
Posted by Lee Nelson <ln...@nelnet.org>.
I should have been clearer. I "unencoded" the URL to make it more
readable. This is what CouchDB is seeing:
[info] [<0.25902.9>] 10.0.1.8 - - 'GET'
/netelligence/_design/telemetry/_view/usage_dates?key=%222010/10/15%2021:20:00%20+0000%22
200
And this is what I get:
{"total_rows":1068,"offset":1,"rows":[]}
So, I'm left wondering why my results are different from yours.
On Mon, Oct 18, 2010 at 9:52 PM, couchdb user <co...@gmail.com> wrote:
> 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 <pa...@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 <ln...@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
>>> }
>>> ]
>>> }
>>> ]
>>> }
>>>
>>
>
Re: Query by specific date vs range
Posted by couchdb user <co...@gmail.com>.
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 <pa...@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 <ln...@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
>> }
>> ]
>> }
>> ]
>> }
>>
>
Re: Query by specific date vs range
Posted by Paul Davis <pa...@gmail.com>.
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 <ln...@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
> }
> ]
> }
> ]
> }
>