Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 40293 invoked from network); 2 Jun 2010 01:01:51 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 Jun 2010 01:01:51 -0000 Received: (qmail 65964 invoked by uid 500); 2 Jun 2010 01:01:49 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 65929 invoked by uid 500); 2 Jun 2010 01:01:49 -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 65913 invoked by uid 99); 2 Jun 2010 01:01:49 -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 01:01:49 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=AWL,HTML_MESSAGE,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of Steven.Prentice@nextgen.net designates 203.18.147.131 as permitted sender) Received: from [203.18.147.131] (HELO smtp12.NextGen.Net) (203.18.147.131) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jun 2010 01:01:43 +0000 Received: from locutus.nextgen.net ([203.18.147.35]) by smtp12.NextGen.Net with ESMTP id 2010060211012159-290541 ; Wed, 2 Jun 2010 11:01:21 +1000 To: user@couchdb.apache.org MIME-Version: 1.0 Subject: Simulating SQL 'LIKE %' using Regular Expressions X-KeepSent: 47EE3CB8:9EA4360A-CA257736:0004B491; type=4; flags=0; name=$KeepSent X-Mailer: Lotus Notes Release 8.0.1 February 07, 2008 Message-ID: From: Steven.Prentice@nextgen.net Date: Wed, 2 Jun 2010 11:01:21 +1000 X-MIMETrack: Serialize by Router on Locutus/NextGen Systems at 02/06/2010 11:01:22 AM, Serialize complete at 02/06/2010 11:01:22 AM, Itemize by SMTP Server on SMTP12/NextGenEXT at 02/06/2010 11:01:21, Serialize by Router on SMTP12/NextGenEXT at 02/06/2010 11:01:42, Serialize complete at 02/06/2010 11:01:42 Content-Type: multipart/alternative; boundary="=_alternative 00059DDECA257736_=" --=_alternative 00059DDECA257736_= Content-Type: text/plain; charset="US-ASCII" Hi, so in my couchDB, what I want to happen is when you query a view in the design doc and providing ?key="C" at the end, bring up all shop names that start with C. to do this I have made the following map function: function(doc) { for (id in doc.Stores) { var strqry = doc.Stores[id]["name"].match(/^.*/); if (strqry) { emit(strqry, doc.product_name + " qty: " + doc.Stores[id].item_count); } } } When I run this from the temp view in Futon, I get a list of all stores and products (which made me think 'yay it worked, all it needs is a parameter') but when I use: http://host:5984/db/design/name/_view/function?key="C" I get back: {"total_rows":30,"offset":0,"rows":[]} my ultimate aim is to get it working similar to an SQL Like % so if for example I say ?key="C" it will return "Computer Store A" and so on.. I created my function based on this tutorial: http://books.couchdb.org/relax/reference/views-for-sql-jockeys --=_alternative 00059DDECA257736_=--