couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nils Breunese <N.Breun...@vpro.nl>
Subject RE: Mapping multiple entries in an array field? (like tags)
Date Sun, 22 May 2011 09:15:58 GMT
You could get the documents for the individual tags and perform the logic on the client, but
when that's not feasible (and it soon stops being feasible) you'll want to take a look at
couchdb-lucene which allows you to do these kinds of OR queries: https://github.com/rnewson/couchdb-lucene

Nils.
________________________________________
Van: He Shiming [heshiming@gmail.com]
Verzonden: zondag 22 mei 2011 8:59
Aan: user@couchdb.apache.org
Onderwerp: Mapping multiple entries in an array field? (like tags)

Dear Community,

I'm working with documents like this:
{
    "tags": ["python", "couchdb", "web"]
}

I'd like to be able to query this document, by all of the following keys:
"python"
["python", "web"]
["couchdb", "python"]
["web", "python", "couchdb"]

but not by keys such as:
"redis"
["python", "redis"]

It's a tag-like situation. I can have the parameter and the field
sorted in alphabetical order if necessary. But it should support any
number of "tags" as the key.

The only solution I figured, is to compose a list of possible key
combinations in the map function, then emit all of them. And this way,
one view will only be able to handle a fixed number of keys. For that
matter, the function gets really complicated for the 3-key (or above)
query. So I'm wondering if there are better ways to do this.

Thanks!
He Shiming
------------------------------------------------------------------------
 VPRO   www.vpro.nl
------------------------------------------------------------------------

Mime
View raw message