Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 46855 invoked from network); 8 Apr 2011 09:54:02 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Apr 2011 09:54:02 -0000 Received: (qmail 19637 invoked by uid 500); 8 Apr 2011 09:54:00 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 19466 invoked by uid 500); 8 Apr 2011 09:53:57 -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 19334 invoked by uid 99); 8 Apr 2011 09:53:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2011 09:53:55 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of peter.matulla@googlemail.com designates 209.85.161.52 as permitted sender) Received: from [209.85.161.52] (HELO mail-fx0-f52.google.com) (209.85.161.52) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Apr 2011 09:53:48 +0000 Received: by fxm6 with SMTP id 6so3898420fxm.11 for ; Fri, 08 Apr 2011 02:53:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type; bh=U6ac34EwnpjnKK7yPiWUsce+9RKh3SzyOgJsVJQxHQw=; b=pUZPAR60MbVNaxQkNrBWt5LkWLkSh7qpmYDpHdZ6fIoYXJS6Gk/UyEieJIT7WqE6Pm IbPPXKlTy6oIU2ncCuIh5zERnkgDrIaP67a4uZfG/j45I59yy8YTHJNmX2tLc1KgbhvZ gnMaeenbanMcrv+dWXDo1hPvqtc6vFkpv68Hc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=IsjWY/5BoNgjnqWGGl+S+i2KbC72izl/mLpAF6iUJoyuxk9iSTgdykriunui7NStZ6 rg/Qkd7LkH3HJvLcdT/Ntt1DJnPcOiYUHn0IxLkJEofgHSX6wnOq/6Ru9i3ImcijpKT5 p7gqjzLGTCLL38xLA+6bQ0rMHVYdLyHiqVSaM= Received: by 10.223.101.87 with SMTP id b23mr2033730fao.97.1302256408545; Fri, 08 Apr 2011 02:53:28 -0700 (PDT) Received: from [192.168.178.20] (stgt-5f73d6e1.pool.mediaWays.net [95.115.214.225]) by mx.google.com with ESMTPS id n15sm734220fam.36.2011.04.08.02.53.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 08 Apr 2011 02:53:27 -0700 (PDT) Message-ID: <4D9EDB10.3000704@matulla.net> Date: Fri, 08 Apr 2011 11:53:20 +0200 From: Peter Matulla User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; de-DE; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: View advice References: <0A3CF017-6578-4AC4-9149-21A4340F536D@gmail.com> In-Reply-To: X-Enigmail-Version: 1.1.1 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigE6E8AF5FF4398CA5D3C994A0" X-Virus-Checked: Checked by ClamAV on apache.org --------------enigE6E8AF5FF4398CA5D3C994A0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable another approach: http://www.vertigrated.com/blog/2010/04/generic-ad-hoc-queries-in-couchdb= / Peter ------------------------------------------------------------------------ -------- Original Message -------- Subject: Re: View advice From: Olafur Arason To: user@couchdb.apache.org Date: Freitag, 8. April 2011 07:57:25 > You can fake it if you want: >=20 > function(doc) { > if(doc.type =3D=3D "Article" && (doc.location =3D=3D "NY" || doc.loca= tion =3D=3D "CA" )){ > emit(["NYCA", doc.release_date], doc) > } > } >=20 > Or join the discussion about why views should have search fields so thi= s could > be resolved once and for all. >=20 > They it would be: >=20 > function(doc) { > if(doc.type =3D=3D "Article" )){ > emit(doc.release_date, doc, doc.location) > } > } >=20 > then query it with: >=20 > _view/articles?limit=3D5&decending=3Dtrue&search=3D"NY OR CA" >=20 > Btw you only need this to call it from couchapp. It's better not to hav= e the > whole url so you can easily change hosts and even database names > like application-test. >=20 > There is some work going on in this direction and it's important to let= people > know that this is important. >=20 > Regards, > Olafur Arason >=20 > On Fri, Apr 8, 2011 at 03:13, Pierre-Alexandre Lacerte > wrote: >> I am currently trying to create a view to reproduce this SQL query: >> >> SELECT * FROM articles WHERE articles.location=3D"NY" OR articles.loca= tion=3D"CA" ORDER BY articles.release_date DESC >> >> I tried to create a view with a complex key: function(doc) { if(doc.ty= pe =3D=3D "Article") { emit([doc.location, doc.release_date], doc) } } >> >> And then using startkey and endkey to retrieve one location and orderi= ng the result on the release date. >> >> http://myhost.com:8000/mydb/_design/application/_view/articles?startke= y=3D["NY", {}]&endkey=3D["NY"]&limit=3D5&descending=3Dtrue >> >> This works fine. >> >> However, I learned that I cannot send multiple startkeys and endkeys t= o my view. (To mimic WHERE articles.location=3D"NY" OR articles.location=3D= "CA") >> >> How should I design this? (It could happen that I would need to query = for 15 different locations) >> >> So far, I have 3 suggestions: >> 1- Store the view output in its own database, and make a new view to s= ort by release date. I'm not sure if this option will be fast and scale w= ell... >> 2- Use couchdb-lucene. >> 3- Hack my version to support multiple startkeys or endkeys. https://i= ssues.apache.org/jira/browse/COUCHDB-523 >> >> Thanks for your help, >> >> Pierre --------------enigE6E8AF5FF4398CA5D3C994A0 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk2e2xAACgkQ8nTCuOgixFSccQCdHKGcGB2V6h6hvpL50BiCAhVI k+8AoLeTg/G73jHV+Oufxz1R3ILkyA50 =yuCQ -----END PGP SIGNATURE----- --------------enigE6E8AF5FF4398CA5D3C994A0--