Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 19978 invoked from network); 19 Aug 2009 07:44:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 19 Aug 2009 07:44:49 -0000 Received: (qmail 66073 invoked by uid 500); 19 Aug 2009 07:45:07 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 66001 invoked by uid 500); 19 Aug 2009 07:45:07 -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 65990 invoked by uid 99); 19 Aug 2009 07:45:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Aug 2009 07:45:07 +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 (athena.apache.org: domain of fredericmalo@gmail.com designates 209.85.218.211 as permitted sender) Received: from [209.85.218.211] (HELO mail-bw0-f211.google.com) (209.85.218.211) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Aug 2009 07:44:59 +0000 Received: by bwz7 with SMTP id 7so190110bwz.11 for ; Wed, 19 Aug 2009 00:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:message-id:subject:to:content-type; bh=jxbMdBe6vSRQXWgsUxqyT+7X2ulbhKg0aPoAD/z71hA=; b=UfQr+ocTfQhduO2+CDZY4x1LbpzL/rgVihSpgIVU2WBYiP13ynsfUfvpSA5fyF9ANb 9i/jzLHOLLHEq+NQT9qRSFgvEc0n3DWCa/BrABiRAUcP28DOCE2zG7CXzqI0+mpDwfk3 JhWWaEbF1UEMZJLSf1fi5wheX3BffYyrNRtyU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=neKLU1QB9BlPyVefZPmMQNvgQj8kTbQkq1IzpAoKC6XThy/tKNi7gZwnjly7bDtihj XeGFhkewIex+IZDj2JXwc+9yxFIPKjSHI6SB8XZoWUgTppTIDjlUGE/SxkgxPotzgizr suXuhczdldgXMW/KiLY98ABYOZYJWSmcsbjW4= MIME-Version: 1.0 Received: by 10.223.144.82 with SMTP id y18mr1461479fau.74.1250667877136; Wed, 19 Aug 2009 00:44:37 -0700 (PDT) In-Reply-To: References: From: =?ISO-8859-1?Q?Fr=E9d=E9ric_Malo?= Date: Wed, 19 Aug 2009 09:44:17 +0200 Message-ID: Subject: Re: How to code an advanced search To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=0023545bd7608c7aa5047179ceb0 X-Virus-Checked: Checked by ClamAV on apache.org --0023545bd7608c7aa5047179ceb0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thank you Adam, So the JOIN logic is not hosted in couchDB but in the application layer. Th= e benefit is scalability, but a little more work :-) Fr=E9d=E9ric On Mon, Aug 17, 2009 at 23:11, Adam Jacob wrote: > On Sun, Aug 16, 2009 at 1:29 AM, Fr=E9d=E9ric Malo > wrote: > > 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. > > The simple answer is "you can't get there from here", at least not > like you are thinking. You have a couple of options: > > * Refactor each of those questions into a single view for each, with > the key pointing to a list of songs that match. > * As the user adds more options, you are actually adding an extra > request for each view > * Use the built in sorting to get the sort order > * Query all the various required views and return the final result set > > This is following a similar pattern to the ones used by Full text > search engines - you are using CouchDB to create the indexes for you, > which return light-weight data that gets culled based on your > requirements. > > Another option would be to actually put all this data into a full text > engine, and use that. (Solr is a nice option here, and perhaps > couchdb-lucene.) > > Don't be afraid to do a little more work on the systems that talk to > CouchDB - often when you find yourself reaching for a Join, instead > reach for multiple queries and doing the computation of the final > match set yourself. > > Adam > > (I've seen a system that does just this, only with CDB indexes rather > than CouchDB, do very complex queries and filtering against every > hotel in America at very, very high speed.) > > -- > Opscode, Inc. > Adam Jacob, CTO > T: (206) 508-4759 E: adam@opscode.com > --0023545bd7608c7aa5047179ceb0--