couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Shorin <>
Subject Re: Mapping multiple entries in an array field? (like tags)
Date Sun, 22 May 2011 08:28:41 GMT

I think that better would be to return sorted list of lowercase tags
as key and access to them via startkey and endkey params.
?startkey=["couchdb"]&endkey=["couchdb", null]
So you could access to all of them, but only while you're keeping
their order in key. For other combinations (you'd like to start with
python tag, not couchdb) you have to generate another key sequence.

This would be more optimal solution instead of generation of all
available combinations of tags: for 4 tags you would have 24 emitted
records, for 5 - 120, for 6 - 720 and more, and this is without case


On Sun, May 22, 2011 at 10:59 AM, He Shiming <> wrote:
> 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

View raw message