You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by paul jobs <we...@gmail.com> on 2008/12/18 01:43:15 UTC

Doing count of number of messages in inbox using couchdb map reduce

Please point out any mistakes in this approach

doc
<Row id='eef13abe4d9ced6defca304d956c6e58',
key='eef13abe4d9ced6defca304d956c6e58', value={'fromuid': 731179094,
'touid': 1073511011, 'created': '2008-12-16T18:07:03Z', '_rev':
'3348218151', 'replycount': 0, 'msg': 'u sexy', 'reply': None, '_id':
'eef13abe4d9ced6defca304d956c6e58', 'type': None, 'subject': 'how ru
doing'}>

map
function(doc) {  emit(doc.touid, 1) }

reduce
function(keys, values) { return sum(values)}

 for i in anondb.view('_view/truthbox/inboxcount',group=True):
    i
   ....:
   ....:
<Row key=515091294, value=1>
<Row key=518582324, value=1>
<Row key=532196519, value=1>
<Row key=532373444, value=1>
<Row key=601813842, value=1>
<Row key=609913339, value=1>
<Row key=614720525, value=1>
<Row key=636721052, value=1>
<Row key=686146326, value=2>
<Row key=706869488, value=14>
<Row key=717798794, value=1>
<Row key=718088951, value=1>
<Row key=731179094, value=14>
<Row key=745532697, value=9>
<Row key=900415470, value=1>
<Row key=1050876321, value=1>
<Row key=1068236284, value=1>
<Row key=1071620632, value=1>
<Row key=1072476232, value=1>
<Row key=1121661054, value=1>
<Row key=1172596643, value=1>
<Row key=1203429728, value=1>
<Row key=1244712151, value=1>
<Row key=1250229089, value=1>
<Row key=1268327796, value=1>
<Row key=1311018404, value=1>
<Row key=1340916503, value=2>
<Row key=1426542138, value=1>
<Row key=1432823487, value=1>
<Row key=1492661717, value=1>
<Row key=1563677715, value=1>
<Row key=1628382420, value=1>

How do we now get the inbox count for a particular user

anondb.view('_view/truthbox/inboxcount',group=True,key="731179094")
doesnt work?

Re: Doing count of number of messages in inbox using couchdb map reduce

Posted by Paul Davis <pa...@gmail.com>.
The key you're emitting in the view is an integer. The key you're
passing to the query is a string, thus they'll never match.

Try:

anondb.view('_view/truthbox/inboxcount',group=True,key=731179094)

On Wed, Dec 17, 2008 at 7:43 PM, paul jobs <we...@gmail.com> wrote:
> Please point out any mistakes in this approach
>
> doc
> <Row id='eef13abe4d9ced6defca304d956c6e58',
> key='eef13abe4d9ced6defca304d956c6e58', value={'fromuid': 731179094,
> 'touid': 1073511011, 'created': '2008-12-16T18:07:03Z', '_rev':
> '3348218151', 'replycount': 0, 'msg': 'u sexy', 'reply': None, '_id':
> 'eef13abe4d9ced6defca304d956c6e58', 'type': None, 'subject': 'how ru
> doing'}>
>
> map
> function(doc) {  emit(doc.touid, 1) }
>
> reduce
> function(keys, values) { return sum(values)}
>
>  for i in anondb.view('_view/truthbox/inboxcount',group=True):
>    i
>   ....:
>   ....:
> <Row key=515091294, value=1>
> <Row key=518582324, value=1>
> <Row key=532196519, value=1>
> <Row key=532373444, value=1>
> <Row key=601813842, value=1>
> <Row key=609913339, value=1>
> <Row key=614720525, value=1>
> <Row key=636721052, value=1>
> <Row key=686146326, value=2>
> <Row key=706869488, value=14>
> <Row key=717798794, value=1>
> <Row key=718088951, value=1>
> <Row key=731179094, value=14>
> <Row key=745532697, value=9>
> <Row key=900415470, value=1>
> <Row key=1050876321, value=1>
> <Row key=1068236284, value=1>
> <Row key=1071620632, value=1>
> <Row key=1072476232, value=1>
> <Row key=1121661054, value=1>
> <Row key=1172596643, value=1>
> <Row key=1203429728, value=1>
> <Row key=1244712151, value=1>
> <Row key=1250229089, value=1>
> <Row key=1268327796, value=1>
> <Row key=1311018404, value=1>
> <Row key=1340916503, value=2>
> <Row key=1426542138, value=1>
> <Row key=1432823487, value=1>
> <Row key=1492661717, value=1>
> <Row key=1563677715, value=1>
> <Row key=1628382420, value=1>
>
> How do we now get the inbox count for a particular user
>
> anondb.view('_view/truthbox/inboxcount',group=True,key="731179094")
> doesnt work?
>