incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Truemper <truem...@googlemail.com>
Subject Re: map from multiple docs
Date Thu, 17 Dec 2009 22:37:08 GMT
Hi,

> I have a db which stores mail logs. Each log entry is stored as a
> single document. for example (just the relevant fields):
> 
> {
>   "_id": "2b93d795d483b1ca352f6596c5497c7f",
>   "_rev": "1-1463054967",
>   "queueid": "03DBB81E1F",
>   "numrecipients": 1,
>   "fromemail": "officefile631@yahoo.com",
>   "logtype": "message_from"
> }
> 
> {
>   "_id": "5ade1602d52f75a4b35ab6c03aa5d8d9",
>   "_rev": "1-2573414463",
>   "queueid": "03DBB81E1F",
>   "rcptemail": "joe@swinepro.info",
>   "logtype": "message_delivery",
> }
I think you need to do more complex preprocessing of the log files. If you use the queueid
as your document's id you could check if the document already exists and then add the second
log event to the existing document. Assuming that both log events are close together you shouldn't
even create the document before you have come across both events in the log. Then you would
end up with something like that:

{
 "_id":"03DBB81E1F",
  "numrecipients": 1,
  "fromemail": "officefile631@yahoo.com",
  "rcptemail": "joe@swinepro.info",
}

A query for this would be simple.

HTH
Daniel


Mime
View raw message