couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: startkey
Date Mon, 15 Jul 2013 22:26:23 GMT
You'll need to add an element to the key to emit the language. Pseudo code:

for language in doc["languages"]:
     emit([language, doc.kml_id, doc.marker], 1)

Also note that its generally not a good idea to emit the doc as the value.
You should prefer to use include_docs=true in the query string. Emitting 1
allows you to specify "_sum" as a reduce function to get row counts for
specific start/end key pairs.


On Mon, Jul 15, 2013 at 5:07 PM, Stephan Bardubitzki <
stephan@bardubitzki.com> wrote:

> Hi there,
>
> this map function
>
> "map": "function(doc) { if (doc.kml_id && doc.marker) { emit([doc.kml_id,
> doc.marker], doc) } }"
>
> and this startkey
>
> startkey: [id, 0]    --> sorting doc.marker
>
> let me retrieve data from a couch as needed.
>
> Now I got the task to add more languages beside English for description
> properties in an array structure like this
>
> "language": [
>     {
>         "en":{
>
>                 }
>     },
>     {
>          "fr": {
>
>                  }
>     }
> ]
>
> I stuck in figuring out a startkey that let me retrieve the sorted data
> only for a particular language.
>
> Any advice would be really appreciated.
>
> Thanks,
> Stephan
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message