incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Peter Eddy" <peter.e...@gmail.com>
Subject Re: more newbie questions - how to use more than one key in views
Date Thu, 17 Jul 2008 15:47:48 GMT
I've done this using an array in emit(), like so:

emit( [doc.title_slug,doc.language,doc.user_id], doc );

- Peter

On 7/17/08, Sho Fukamachi <sho.fukamachi@gmail.com> wrote:
> Hi all,
>
> another n00b view question from an SQL refugee.
>
> I can't figure out how to use views to search for documents by more
> than one criterion. For example, I have a node-type content DB with
> various properties - user_id, title_slug, and language.
>
> What I can't figure out is how to select by more than one of them at a
> time dynamically, rather than having hard-coded views.
>
> For example, what I'm doing right now is something like this:
>
> "map" => "function(doc) { if (doc.type == 'content_node' &&
> doc.langauge == 'en_AU') emit(doc.title_slug, doc); }"
>
> Problem is I need an additional filter in there and I'm not sure how
> to get it in - and it's far from ideal to hardcode the language. Can I
> have more than one key in the emit function? Any examples of this kind
> of thing anywhere?
>
> I mean, what I really want to do is
>
> "function(doc) { if (doc.type == 'content_node' )
> emit((doc.title_slug, doc.language, doc.user_id), doc); }"
>
> but somehow I don't think it works like that.
>
> Any hints? Examples of similar solutions? Or, just as welcome,
> suggestions that I am coming at this from a totally wrong direction
> and advice on what I should really be doing?
>
> thank you,
>
> Sho

Mime
View raw message