From user-return-6013-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Sun Aug 16 08:30:46 2009 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 15905 invoked from network); 16 Aug 2009 08:30:46 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 16 Aug 2009 08:30:46 -0000 Received: (qmail 5780 invoked by uid 500); 16 Aug 2009 08:30:52 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 5680 invoked by uid 500); 16 Aug 2009 08:30:51 -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 5670 invoked by uid 99); 16 Aug 2009 08:30:51 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Aug 2009 08:30:51 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of fredericmalo@gmail.com designates 209.85.218.209 as permitted sender) Received: from [209.85.218.209] (HELO mail-bw0-f209.google.com) (209.85.218.209) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Aug 2009 08:30:41 +0000 Received: by bwz5 with SMTP id 5so1903978bwz.3 for ; Sun, 16 Aug 2009 01:30:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=qxzYa2WzQz1OLyoKppIKIoRut2lBZmgaV1tjnOXOViI=; b=n6IHwD/nRWT4lFJlhH664NQ5Rf7y9FaxXcQeSpH03Soq+Ue1hkIChb3RMcJcm4NDIC QjFQ1eXJU59SVizv4wp09iay1GvUd64npXXNXpAi2IjGz7NCBEv2t0Hv96gpjzZPnbOe PoswMGzR/Nz2Ct3jXjmumy0uTCfv0fiL1UqM0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=C/+O4AZy3N+brNBywTQhitua0kUle3hfjPFfDFxVEfjBClzWvk0hfNArG/nXReu577 Z7p904+Jgy0iSXij55ksVj8pvGcvDg1RbTMDiWxlazCf56Ig1VzTnMjkl7tBQdeRHtaN 7slOhVrGx64l6fxcG3YpZlLMMBTYvoQb/xr0A= MIME-Version: 1.0 Received: by 10.223.143.73 with SMTP id t9mr692212fau.14.1250411418085; Sun, 16 Aug 2009 01:30:18 -0700 (PDT) From: =?ISO-8859-1?Q?Fr=E9d=E9ric_Malo?= Date: Sun, 16 Aug 2009 10:29:58 +0200 Message-ID: Subject: How to code an advanced search To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0023545bdaac65ea7b04713e1854 X-Virus-Checked: Checked by ClamAV on apache.org --0023545bdaac65ea7b04713e1854 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Hello, I would like to create an "advanced search" for a couchDB database, and I don't know how to do it without reduce. The documentation warns me not to follow this strategy : A common mistake new CouchDB users make, is attempting to construct complex aggregate values with a reduce function. Full reductions should result in a scalar value, like 5, not, for instance, a JSON hash with the set of unique keys, and the count of each. The problem with this approach is that you=92l= l end up with a very very large final value. The number of unique keys can be nearly as large as the number of total keys, even for a large set. It is fine to combine a few scalar calculations into one reduce function, for instance to find the total, average, and standard deviation of a set of numbers in a single function. http://books.couchdb.org/relax/design-documents/views For example, imagine a music database as iTunes. I would like to create a script to query such as : Sort all songs by genre then album : - with 3 or 5 stars - artist name matching "floyd" - duration between 5 and 8 minutes - heard last week (perhaps another couch database, logging user actions) - .... All the parameters are optional. Users can choose to filter with only 2 or = 5 parameters. Other parameters should be added. My first reflex is to think like sql with index and joins. But how to code it with views and reduce ? Thank you for all, couchDB users ! Fr=E9d=E9ric --0023545bdaac65ea7b04713e1854--