You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by armin weisser <ar...@virtual-identity.com> on 2011/04/28 11:25:31 UTC

total_rows:1 but rows:[]

Hi there,

 

can anyone tell me why total_rows is 1 when rows is empty?

I'd expect total_rows:0. Or do I miss something?

 

{"total_rows":1,"offset":0,"rows":[]}

 

Cheers,

 

Armin

 


Re: AW: total_rows:1 but rows:[]

Posted by N/A N/A <pr...@yahoo.com>.
Hi,

Well, you answer yourself i think in the last line:
http://localhost:5984/mydb/_design/views/_view/names?key="unknown"

If there is account "unknown" you will get results. Else it tells you, that you 
got 1 user in your document, but your key doesnt match any of them, so no 
result.

It shows that your view found for example 10 records(jobjects), but your key 
matched only X of them.

Consider the example to GET document without key and see the results. Next try 
with valid key with valid user.
Why your key is unknown ? Expected behavior ? Desired results ?

regards,



________________________________
From: armin weisser <ar...@virtual-identity.com>
To: user@couchdb.apache.org
Sent: Thu, April 28, 2011 12:42:18 PM
Subject: AW: total_rows:1 but rows:[]


What do you mean with "overall rows info". Is that a config or request param?

The mapping function is very simple.

"names":{
    "map": "function(doc) { emit(doc.account.username, true) }"
}

The document looks like:

{
    "_id":...,
    "_rev":...,
    "account { 
          "name":"a name",
         "pwd":" a pwd"
    }
}

The query is 
http://localhost:5984/mydb/_design/views/_view/names?key="unknown"

-----Ursprüngliche Nachricht-----
Von: N/A N/A [mailto:pressley333@yahoo.com] 
Gesendet: Donnerstag, 28. April 2011 11:29
An: user@couchdb.apache.org
Betreff: Re: total_rows:1 but rows:[]

Hi,

Maybe your overall rows info is 1, but your key filter doesnt match any of them.

regards,



________________________________
From: armin weisser <ar...@virtual-identity.com>
To: user@couchdb.apache.org
Sent: Thu, April 28, 2011 12:25:31 PM
Subject: total_rows:1 but rows:[]

Hi there,



can anyone tell me why total_rows is 1 when rows is empty?

I'd expect total_rows:0. Or do I miss something?



{"total_rows":1,"offset":0,"rows":[]}



Cheers,



Armin

AW: total_rows:1 but rows:[]

Posted by armin weisser <ar...@virtual-identity.com>.
> The built-in _count function is the fastest method.

Thanks. That helps!

-----Ursprüngliche Nachricht-----
Von: Robert Newson [mailto:robert.newson@gmail.com] 
Gesendet: Donnerstag, 28. April 2011 12:22
An: user@couchdb.apache.org
Betreff: Re: total_rows:1 but rows:[]

total_rows is the total number rows in the view, not the query. This often confuses people.

Yes, you'll need to use reduce to count the number of rows. The built-in _count function is the fastest method.

B.

On 28 April 2011 11:13, armin weisser
<ar...@virtual-identity.com> wrote:
>>> Do you mean "number of pages" (in terms of pagination) when you say "records".
>>> That would make sense. So we'd have 1 page but no documents to display.
>
>> when i say record, i normally mean record ;) in couchdb-speek it's a document.
> ;)
>
>
> Ok. I think I got it.
>
> So if I'm interested in the question "Are there any documents matching the key?" I have to manually count the rows or use a reduce function.
>
> Thanks for your help.
>
> Cheers,
>
> Armin
>
>
> -----Ursprüngliche Nachricht-----
> Von: Stefan Matheis [mailto:matheis.stefan@googlemail.com]
> Gesendet: Donnerstag, 28. April 2011 12:03
> An: user@couchdb.apache.org
> Betreff: Re: total_rows:1 but rows:[]
>
> Armin,
>
> On Thu, Apr 28, 2011 at 11:53 AM, armin weisser <ar...@virtual-identity.com> wrote:
>> Do you mean "number of pages" (in terms of pagination) when you say "records".
>> That would make sense. So we'd have 1 page but no documents to display.
>
> when i say record, i normally mean record ;) in couchdb-speek it's a document.
>
> it's not directly related to pagination .. of course helpful to 
> calculate pages and so on, but in general it tells you only how many
> (possible) records/documents this view has. and this is (like said) the case when you request the view without any parameters that would exclude some records/documents.
>
> Regards
> Stefan
>

Re: total_rows:1 but rows:[]

Posted by Robert Newson <ro...@gmail.com>.
total_rows is the total number rows in the view, not the query. This
often confuses people.

Yes, you'll need to use reduce to count the number of rows. The
built-in _count function is the fastest method.

B.

On 28 April 2011 11:13, armin weisser
<ar...@virtual-identity.com> wrote:
>>> Do you mean "number of pages" (in terms of pagination) when you say "records".
>>> That would make sense. So we'd have 1 page but no documents to display.
>
>> when i say record, i normally mean record ;) in couchdb-speek it's a document.
> ;)
>
>
> Ok. I think I got it.
>
> So if I'm interested in the question "Are there any documents matching the key?" I have to manually count the rows or use a reduce function.
>
> Thanks for your help.
>
> Cheers,
>
> Armin
>
>
> -----Ursprüngliche Nachricht-----
> Von: Stefan Matheis [mailto:matheis.stefan@googlemail.com]
> Gesendet: Donnerstag, 28. April 2011 12:03
> An: user@couchdb.apache.org
> Betreff: Re: total_rows:1 but rows:[]
>
> Armin,
>
> On Thu, Apr 28, 2011 at 11:53 AM, armin weisser <ar...@virtual-identity.com> wrote:
>> Do you mean "number of pages" (in terms of pagination) when you say "records".
>> That would make sense. So we'd have 1 page but no documents to display.
>
> when i say record, i normally mean record ;) in couchdb-speek it's a document.
>
> it's not directly related to pagination .. of course helpful to calculate pages and so on, but in general it tells you only how many
> (possible) records/documents this view has. and this is (like said) the case when you request the view without any parameters that would exclude some records/documents.
>
> Regards
> Stefan
>

AW: total_rows:1 but rows:[]

Posted by armin weisser <ar...@virtual-identity.com>.
>> Do you mean "number of pages" (in terms of pagination) when you say "records".
>> That would make sense. So we'd have 1 page but no documents to display.

> when i say record, i normally mean record ;) in couchdb-speek it's a document.
;)


Ok. I think I got it.

So if I'm interested in the question "Are there any documents matching the key?" I have to manually count the rows or use a reduce function.

Thanks for your help.

Cheers,

Armin


-----Ursprüngliche Nachricht-----
Von: Stefan Matheis [mailto:matheis.stefan@googlemail.com] 
Gesendet: Donnerstag, 28. April 2011 12:03
An: user@couchdb.apache.org
Betreff: Re: total_rows:1 but rows:[]

Armin,

On Thu, Apr 28, 2011 at 11:53 AM, armin weisser <ar...@virtual-identity.com> wrote:
> Do you mean "number of pages" (in terms of pagination) when you say "records".
> That would make sense. So we'd have 1 page but no documents to display.

when i say record, i normally mean record ;) in couchdb-speek it's a document.

it's not directly related to pagination .. of course helpful to calculate pages and so on, but in general it tells you only how many
(possible) records/documents this view has. and this is (like said) the case when you request the view without any parameters that would exclude some records/documents.

Regards
Stefan

Re: total_rows:1 but rows:[]

Posted by Stefan Matheis <ma...@googlemail.com>.
Armin,

On Thu, Apr 28, 2011 at 11:53 AM, armin weisser
<ar...@virtual-identity.com> wrote:
> Do you mean "number of pages" (in terms of pagination) when you say "records".
> That would make sense. So we'd have 1 page but no documents to display.

when i say record, i normally mean record ;) in couchdb-speek it's a document.

it's not directly related to pagination .. of course helpful to
calculate pages and so on, but in general it tells you only how many
(possible) records/documents this view has. and this is (like said)
the case when you request the view without any parameters that would
exclude some records/documents.

Regards
Stefan

AW: total_rows:1 but rows:[]

Posted by armin weisser <ar...@virtual-identity.com>.
Hi Stefan, 

Do you mean "number of pages" (in terms of pagination) when you say "records".
That would make sense. So we'd have 1 page but no documents to display.

I thought that the "rows" param corresponds to "number of documents in the result set" or "size of result set" respectivaly.

Cheers,
Armin


-----Ursprüngliche Nachricht-----
Von: Stefan Matheis [mailto:matheis.stefan@googlemail.com] 
Gesendet: Donnerstag, 28. April 2011 11:45
An: user@couchdb.apache.org
Betreff: Re: total_rows:1 but rows:[]

Armin,

On Thu, Apr 28, 2011 at 11:42 AM, armin weisser <ar...@virtual-identity.com> wrote:
> What do you mean with "overall rows info". Is that a config or request param?

it's telling you how many records the view would output - without any restriction. so if you have one document where the value of account.username is "foo" and you request that view with key=bar ..
the counter will still show 1 as counter, but output 0 (=zero) documents.

Regards
Stefan

Re: total_rows:1 but rows:[]

Posted by Stefan Matheis <ma...@googlemail.com>.
Armin,

On Thu, Apr 28, 2011 at 11:42 AM, armin weisser
<ar...@virtual-identity.com> wrote:
> What do you mean with "overall rows info". Is that a config or request param?

it's telling you how many records the view would output - without any
restriction. so if you have one document where the value of
account.username is "foo" and you request that view with key=bar ..
the counter will still show 1 as counter, but output 0 (=zero)
documents.

Regards
Stefan

AW: total_rows:1 but rows:[]

Posted by armin weisser <ar...@virtual-identity.com>.
Sorry the map function is

"names":{
	"map": "function(doc) { emit(doc.account.name, true) }"
}

-----Ursprüngliche Nachricht-----
Von: armin weisser [mailto:armin.weisser@virtual-identity.com] 
Gesendet: Donnerstag, 28. April 2011 11:42
An: user@couchdb.apache.org
Betreff: AW: total_rows:1 but rows:[]


What do you mean with "overall rows info". Is that a config or request param?

The mapping function is very simple.

"names":{
	"map": "function(doc) { emit(doc.account.username, true) }"
}

The document looks like:

{
	"_id":...,
	"_rev":...,
	"account { 
	  	"name":"a name",
		 "pwd":" a pwd"
	}
}

The query is 
http://localhost:5984/mydb/_design/views/_view/names?key="unknown"

-----Ursprüngliche Nachricht-----
Von: N/A N/A [mailto:pressley333@yahoo.com] 
Gesendet: Donnerstag, 28. April 2011 11:29
An: user@couchdb.apache.org
Betreff: Re: total_rows:1 but rows:[]

Hi,

Maybe your overall rows info is 1, but your key filter doesnt match any of them.

regards,



________________________________
From: armin weisser <ar...@virtual-identity.com>
To: user@couchdb.apache.org
Sent: Thu, April 28, 2011 12:25:31 PM
Subject: total_rows:1 but rows:[]

Hi there,



can anyone tell me why total_rows is 1 when rows is empty?

I'd expect total_rows:0. Or do I miss something?



{"total_rows":1,"offset":0,"rows":[]}



Cheers,



Armin

AW: total_rows:1 but rows:[]

Posted by armin weisser <ar...@virtual-identity.com>.
What do you mean with "overall rows info". Is that a config or request param?

The mapping function is very simple.

"names":{
	"map": "function(doc) { emit(doc.account.username, true) }"
}

The document looks like:

{
	"_id":...,
	"_rev":...,
	"account { 
	  	"name":"a name",
		 "pwd":" a pwd"
	}
}

The query is 
http://localhost:5984/mydb/_design/views/_view/names?key="unknown"

-----Ursprüngliche Nachricht-----
Von: N/A N/A [mailto:pressley333@yahoo.com] 
Gesendet: Donnerstag, 28. April 2011 11:29
An: user@couchdb.apache.org
Betreff: Re: total_rows:1 but rows:[]

Hi,

Maybe your overall rows info is 1, but your key filter doesnt match any of them.

regards,



________________________________
From: armin weisser <ar...@virtual-identity.com>
To: user@couchdb.apache.org
Sent: Thu, April 28, 2011 12:25:31 PM
Subject: total_rows:1 but rows:[]

Hi there,



can anyone tell me why total_rows is 1 when rows is empty?

I'd expect total_rows:0. Or do I miss something?



{"total_rows":1,"offset":0,"rows":[]}



Cheers,



Armin

Re: total_rows:1 but rows:[]

Posted by N/A N/A <pr...@yahoo.com>.
Hi,

Maybe your overall rows info is 1, but your key filter doesnt match any of them.

regards,



________________________________
From: armin weisser <ar...@virtual-identity.com>
To: user@couchdb.apache.org
Sent: Thu, April 28, 2011 12:25:31 PM
Subject: total_rows:1 but rows:[]

Hi there,



can anyone tell me why total_rows is 1 when rows is empty?

I'd expect total_rows:0. Or do I miss something?



{"total_rows":1,"offset":0,"rows":[]}



Cheers,



Armin