incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul J. Davis" <paul.joseph.da...@gmail.com>
Subject Re: Help With map function
Date Wed, 23 Feb 2011 02:19:04 GMT


On Feb 22, 2011, at 9:06 PM, Javier Julio <jjfutbol@gmail.com> wrote:

> Paul, thanks for confirming. Can you elaborate on "the non-wildcard selection criteria
as a leading prefix"? What does that mean?
> 
> So to handle an AND/OR statement would best be or perhaps only way to do with multiple
views? So since Andrey wanted to support "brand and category" or "brand or category" he would
need 3 views right?
> 

The root is that CouchDB views don't do OR queries.  For AND the terms need to be ordered
so you can apply left to right.

In a funny aside, one of the amusing from couchdb-lucene is "for when you want foo OR bar".

> One for item, brand and category, second for item and brand, and the third for item and
category?
> 
> On Feb 22, 2011, at 9:01 PM, Paul J. Davis wrote:
> 
>> Yep, the multi-key post doesn't require string keys.
>> 
>> Also, when you want wild card behavior you need a view that has the non-wildcard
selection criteria as a leading prefix. It's easiest to think about in terms of array slicing.
>> 
>> For the OP I would suggest multiple views with the required array orders for the
expected queries.  
>> 
>> On Feb 22, 2011, at 8:52 PM, Javier Julio <jjfutbol@gmail.com> wrote:
>> 
>>> Andrey,
>>> 
>>> Great question as I had been struggling with the same. In the docs its kind of
buried there but you can post multiple keys to a view. I believe this is what you are looking
for. Correct me if I'm wrong. So I'd create a view where the index has item, brand and category
and then you can just include a key set for each grouping you want in the post body.
>>> 
>>> If you look under the table with all the query params in this section of the
View docs: http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options you'll see a that
it mentions you can post multiple keys to a view.
>>> 
>>> I'm still learning myself so I'm not sure if you can post complex keys (only
simple strings are used). I would assume so since its not stated otherwise but I believe this
is what will solve your problem.
>>> 
>>> Ciao!
>>> Javi
>>> 
>>> On Feb 22, 2011, at 8:06 PM, Andrey Cherkashin wrote:
>>> 
>>>> Hello,
>>>> 
>>>> I have a problem, I can't understand how to write map function that solves
my problem:
>>>> 
>>>> I have a lot of "documents", each document has type (e.g. item,  user), category
and brand. So i have map functions that gives me a list of every document that has type item
(that's easy), but how i can get list of all documents that has brand == xxx or category ==
yyy or even brand==xxx&category=zzz (xxx,yyy,zzz different every time).
>>> 
> 

Mime
  • Unnamed multipart/alternative (inline, 7-Bit, 0 bytes)
View raw message