Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 66363 invoked from network); 22 Jan 2009 17:09:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 22 Jan 2009 17:09:09 -0000 Received: (qmail 86461 invoked by uid 500); 22 Jan 2009 17:09:06 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 86432 invoked by uid 500); 22 Jan 2009 17:09:06 -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 86421 invoked by uid 99); 22 Jan 2009 17:09:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jan 2009 09:09:06 -0800 X-ASF-Spam-Status: No, hits=2.4 required=10.0 tests=NORMAL_HTTP_TO_IP,SPF_PASS,URIBL_RHS_DOB,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 209.85.198.233 as permitted sender) Received: from [209.85.198.233] (HELO rv-out-0506.google.com) (209.85.198.233) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 22 Jan 2009 17:08:59 +0000 Received: by rv-out-0506.google.com with SMTP id g37so4250636rvb.35 for ; Thu, 22 Jan 2009 09:08:39 -0800 (PST) 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 :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=AcsTrKJzTcwO81gS+q0SLllJhUMdv0H4BnGY+E5/x3o=; b=xG/1sSLl3VdBcHJWOadVFaCNdgM1j0KXSSL6uhWVP034njTwGSZzzo46uLfanquuKO tUL3nrs2bOhvlL2VGFXBomc/G17AuFkUuP0dz+moR0Sov0PSbyKbiuEyePIykWPKIaHc LfBXSxbbVkD8Jf1XDrrO2/D7gyZVc9BFELBh0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=s5r8O3QTilJ/g2YKvD1MjIj3uI8sWPc1RU0OO4gsxrXheo1IfV0Tgvfj1isH39Kr1t iQv7+olLhVpW7UWEVYxtpIMz1WTreGlYJ3dZfgr7iK1rWSYMgKwKEKY3t3SXR2RUiIMR hNzVytR0/2D7knJo7jXGScyf/YZDs+IpINlVs= MIME-Version: 1.0 Received: by 10.140.177.15 with SMTP id z15mr1797779rve.17.1232644119083; Thu, 22 Jan 2009 09:08:39 -0800 (PST) In-Reply-To: <20090122165608.GA28398@uk.tiscali.com> References: <20090122165608.GA28398@uk.tiscali.com> Date: Thu, 22 Jan 2009 12:08:39 -0500 Message-ID: Subject: Re: Newbie question: substring matching From: Paul Davis To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org You'll never be able to have a wildcard on the front side of your pattern with couchdb directly, and you'll only be able to have a wild card on one end of the statement. Something you could try: emit(doc.field_to_search, value); emit(string_reverse_function(doc.field_to_search), vaule); Then you could do something like: http://127.0.0.1:5984/db_name/_view/ddoc/using_like?startkey="foo"&endkey="foo\u9999" http://127.0.0.1:5984/db_name/_view/ddoc/using_like?startkey="oof"&endkey="oof\u9999" And then intersect the two sets client side. Other than that, I'd look at integrating full text search. HTH, Paul Davis On Thu, Jan 22, 2009 at 11:56 AM, Brian Candler wrote: > Suppose I have a view which indexes a single field. Using startkey and > endkey, it's easy to find matches which start with a particular pattern. > > But I'm wondering how best to do substring matches (in SQL: LIKE '%foo%') > > I could: > > 1. Read the entire view, and filter it client-side (problem: large > data transfer) > > 2. Create another view which enumerates all possible suffixes (problem: > large index, O(N^2)) > > somedata > omedata > medata > edata > data > ata > ta > a > > 3. Create a temporary view for the exact search being done (problem: forces > a read through all documents in the database) > > Is there some other option I have overlooked, such as filtering the view > server-side somehow? > > Thanks, > > Brian. >