From user-return-15029-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Wed Feb 23 02:19:43 2011 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 17180 invoked from network); 23 Feb 2011 02:19:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 23 Feb 2011 02:19:42 -0000 Received: (qmail 29075 invoked by uid 500); 23 Feb 2011 02:19:41 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 29032 invoked by uid 500); 23 Feb 2011 02:19:40 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 29024 invoked by uid 99); 23 Feb 2011 02:19:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Feb 2011 02:19:40 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,MIME_QP_LONG_LINE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.214.180 as permitted sender) Received: from [209.85.214.180] (HELO mail-iw0-f180.google.com) (209.85.214.180) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 23 Feb 2011 02:19:33 +0000 Received: by iwn6 with SMTP id 6so2887357iwn.11 for ; Tue, 22 Feb 2011 18:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:references:from:content-type:x-mailer :in-reply-to:message-id:date:to:content-transfer-encoding :mime-version; bh=jz/d3KqyvGZqTL8qAibmLo9763aCCHBd6CdFQKLAfl4=; b=N9EfrFUFC/HVaozI3SSkRnV8CEHwJSGxH7Tb9MQBERF9FQuI5Hk0Xq3bGwi5xyDgvY 7JWw4CYbQfoboJ+OXPa8P55XUwTWxcTJRTa/AB7VFqhm9Z1EiwXU6rw7+LtjKOsm9ng7 kzRmmIADDf5se3Mz8D08kqRGMUdOhmgruHJQo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:references:from:content-type:x-mailer:in-reply-to :message-id:date:to:content-transfer-encoding:mime-version; b=WelvHdPLyron7qS/1E/EGGRGA2tyR8cOphXkI1smGzXE2kwfIz5R/6U+fSTnmzw1nf ktEP/McLMKgjA+5ldVhM9IpxJEERhhqWHYs2RmMAWo1mwlW40AG2uXnlRobrN7/lVSZL vDxR+w7HHFYLOBABi964Pzx+TTTwCSrIXL//U= Received: by 10.42.229.9 with SMTP id jg9mr4495013icb.146.1298427552620; Tue, 22 Feb 2011 18:19:12 -0800 (PST) Received: from [10.58.201.183] (mobile-166-137-137-111.mycingular.net [166.137.137.111]) by mx.google.com with ESMTPS id i16sm6736364ibl.6.2011.02.22.18.19.10 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Feb 2011 18:19:11 -0800 (PST) Subject: Re: Help With map function References: <28D2E88E-D082-47F0-91BE-D6902CAFD10A@GMAIL.COM> <2BB3938D-F3E1-4A8D-9A03-01C4401552AC@gmail.com> From: "Paul J. Davis" Content-Type: multipart/alternative; boundary=Apple-Mail-7-145286311 X-Mailer: iPhone Mail (8C148) In-Reply-To: Message-Id: Date: Tue, 22 Feb 2011 21:19:04 -0500 To: "user@couchdb.apache.org" Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (iPhone Mail 8C148) --Apple-Mail-7-145286311 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Feb 22, 2011, at 9:06 PM, Javier Julio wrote: > Paul, thanks for confirming. Can you elaborate on "the non-wildcard select= ion criteria as a leading prefix"? What does that mean? >=20 > So to handle an AND/OR statement would best be or perhaps only way to do w= ith multiple views? So since Andrey wanted to support "brand and category" o= r "brand or category" he would need 3 views right? >=20 The root is that CouchDB views don't do OR queries. For AND the terms need t= o be ordered so you can apply left to right. In a funny aside, one of the amusing from couchdb-lucene is "for when you wa= nt foo OR bar". > One for item, brand and category, second for item and brand, and the third= for item and category? >=20 > On Feb 22, 2011, at 9:01 PM, Paul J. Davis wrote: >=20 >> Yep, the multi-key post doesn't require string keys. >>=20 >> Also, when you want wild card behavior you need a view that has the non-w= ildcard selection criteria as a leading prefix. It's easiest to think about i= n terms of array slicing. >>=20 >> For the OP I would suggest multiple views with the required array orders f= or the expected queries. =20 >>=20 >> On Feb 22, 2011, at 8:52 PM, Javier Julio wrote: >>=20 >>> Andrey, >>>=20 >>> Great question as I had been struggling with the same. In the docs its k= ind 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 w= here the index has item, brand and category and then you can just include a k= ey set for each grouping you want in the post body. >>>=20 >>> 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_Option= s you'll see a that it mentions you can post multiple keys to a view. >>>=20 >>> 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 otherw= ise but I believe this is what will solve your problem. >>>=20 >>> Ciao! >>> Javi >>>=20 >>> On Feb 22, 2011, at 8:06 PM, Andrey Cherkashin wrote: >>>=20 >>>> Hello, >>>>=20 >>>> I have a problem, I can't understand how to write map function that sol= ves my problem: >>>>=20 >>>> 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 d= ocument that has type item (that's easy), but how i can get list of all docu= ments that has brand =3D=3D xxx or category =3D=3D yyy or even brand=3D=3Dxx= x&category=3Dzzz (xxx,yyy,zzz different every time). >>>=20 >=20 --Apple-Mail-7-145286311--