From user-return-10806-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Wed Jun 02 08:01:33 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 39770 invoked from network); 2 Jun 2010 08:01:33 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 08:01:33 -0000 Received: (qmail 50027 invoked by uid 500); 2 Jun 2010 08:01:31 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 49994 invoked by uid 500); 2 Jun 2010 08:01:31 -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 49914 invoked by uid 99); 2 Jun 2010 08:01:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 08:01:30 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=AWL,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [209.85.211.182] (HELO mail-yw0-f182.google.com) (209.85.211.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 08:01:26 +0000 Received: by ywh12 with SMTP id 12so5840256ywh.19 for ; Wed, 02 Jun 2010 01:01:04 -0700 (PDT) MIME-Version: 1.0 Received: by 10.151.115.14 with SMTP id s14mr7594973ybm.321.1275465664371; Wed, 02 Jun 2010 01:01:04 -0700 (PDT) Received: by 10.231.204.74 with HTTP; Wed, 2 Jun 2010 01:01:04 -0700 (PDT) In-Reply-To: References: Date: Wed, 2 Jun 2010 20:01:04 +1200 Message-ID: Subject: Re: Simulating SQL 'LIKE %' using Regular Expressions From: Dave Cottlehuber To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 On 2 June 2010 17:11, wrote: > hmm... > > so would that mean that if I typed in ?key="Image/" [...] > similar to saying select mime-type * from some_table where mime-type LIKE > %/% > > or am I reading this wrong The example on the book http://books.couchdb.org/relax/reference/views-for-sql-jockeys could be construed as misleading. What you (& lots of others want) is to allow the user to enter any search expression which in real time is filtered against the DB, & a bunch of docs made available for further actions. My case is I have a bunch of devices (device1.abc.com, device2.def.org etc etc) and want to enable somebody to search for "def" or "device1" or any combo & then to return an array of those _ids to work with. The issue here is that the index you use (the map) must be able to be pre-calculated & stored in the B+tree for each doc. A regex search can't by nature be pre-calculated if you can put anything you like in. So you need somewhere (browser, middle tier, search engine like lucence) to process that. The book example simply splits up using a pre-existing regex & allows you to filter using that instead. I've not tried this but had thought that for some use cases with short keys and/or low doc volumes, you can pass the whole index from your map fun "emit (doc._id, key)" style across to your web page via ajax and do the filtering there. If you're going to re-use this field, and it can be cached both proxy layer and in browser the initial hit of several 10-100KB might be an acceptable trade-off to load the index down. Are there any other options? A+ D