Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AE650C486 for ; Sun, 27 May 2012 07:25:27 +0000 (UTC) Received: (qmail 18872 invoked by uid 500); 27 May 2012 07:25:26 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 18381 invoked by uid 500); 27 May 2012 07:25:25 -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 18356 invoked by uid 99); 27 May 2012 07:25:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 May 2012 07:25:24 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of martinh@gmail.com designates 209.85.160.52 as permitted sender) Received: from [209.85.160.52] (HELO mail-pb0-f52.google.com) (209.85.160.52) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 27 May 2012 07:25:16 +0000 Received: by pbbro8 with SMTP id ro8so3898456pbb.11 for ; Sun, 27 May 2012 00:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=pgT2XePZawX3ikF/6LHWdOqSMawhYR5v8kqc3EoaFFQ=; b=GQbMuvFdZ2D3W2G+sxjR7GPyYplSa2AKWXZ0U+gkirI0i08x5lsYCNK2A+/WV5y4Nw Tza2rzIbplqyHzRTuKiUTT37lqPcbzRDQUf8VvFFTAUplaITdn80eoU59XvQia1f7/Ir Fvv/CNc10jqeM0GblQnLhbMLeRAre/uQc0FsIdL1PySORadpvsjLpjZRP/PdA6qE2NFD o+lpZYElAT5QqLZ8qoGIedEXln6RQO4coTREdmQq4v04B61nqv4w+fNxc4aVsq4cb7Ci z1Aahzp2of8mrcOSXZGA7Nv9NVyw6aMrd/vRTUgRBUbU+zGp4T1R9Pc2NyuFBJwQcYMx QjIQ== MIME-Version: 1.0 Received: by 10.68.227.227 with SMTP id sd3mr14144509pbc.53.1338103495554; Sun, 27 May 2012 00:24:55 -0700 (PDT) Sender: martinh@gmail.com Received: by 10.68.239.136 with HTTP; Sun, 27 May 2012 00:24:55 -0700 (PDT) In-Reply-To: References: Date: Sun, 27 May 2012 08:24:55 +0100 X-Google-Sender-Auth: 6bxuL_NQYPIN21Ti1zgq8XlYbOc Message-ID: Subject: Re: how to make queries with logical operators? From: Martin Higham To: "user@couchdb.apache.org" Content-Type: multipart/alternative; boundary=e89a8ff24bcb86760904c0ff7f17 --e89a8ff24bcb86760904c0ff7f17 Content-Type: text/plain; charset=ISO-8859-1 Yes, you need to write a view with a map function ( http://wiki.apache.org/couchdb/HTTP_view_API) that emits an index of the doc type. e.g. emit(doc.type, doc) and then pass an array of the types you want to retrieve as the keys query parameter to the view For instance if you called the design document mydesign and the view byType, the http request (before encoding) would be: http://localhost:5984/database/_design/mydesign/_view/byType?keys=["a","b"] On Sunday, 27 May 2012, Patrick Maia wrote: > Hi all, imagine I have a database that stores documents like these: > > { "type":"a", "attr1":"value1.1", "attr2":"value2.1"} > { "type":"a", "attr1":"value1.2", "attr2":"value2.2"} > { "type":"b", "attr3":"value3"} > { "type":"c", "attr4":"value4"} > > Is there some way to get all docs where type == "a" or type == "b" doing > just one http request to couchdb? > > Thanks, > > Patrick Maia > --e89a8ff24bcb86760904c0ff7f17--