From user-return-14144-apmail-couchdb-user-archive=couchdb.apache.org@couchdb.apache.org Thu Dec 09 22:57:35 2010 Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 50547 invoked from network); 9 Dec 2010 22:57:35 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 9 Dec 2010 22:57:35 -0000 Received: (qmail 68963 invoked by uid 500); 9 Dec 2010 22:57:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 68936 invoked by uid 500); 9 Dec 2010 22:57:33 -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 68928 invoked by uid 99); 9 Dec 2010 22:57:33 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Dec 2010 22:57:33 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [207.58.155.150] (HELO vps.myquickref.com) (207.58.155.150) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Dec 2010 22:57:27 +0000 Received: from ppp118-209-23-70.lns20.mel4.internode.on.net ([118.209.23.70] helo=[192.168.1.40]) by vps.myquickref.com with esmtpa (Exim 4.69) (envelope-from ) id 1PQpQA-00027v-Ee; Thu, 09 Dec 2010 17:57:06 -0500 Date: Fri, 10 Dec 2010 09:56:45 +1100 From: Neville Franks Reply-To: subs@surfulater.com Organization: Soft As It Gets Pty Ltd X-Priority: 3 (Normal) Message-ID: <337610917.20101210095645@surfulater.com> To: user , user@couchdb.apache.org Subject: View with key1 and key2 query MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps.myquickref.com X-AntiAbuse: Original Domain - couchdb.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - surfulater.com X-Source: X-Source-Args: X-Source-Dir: Hi, I am interested in a document model like that described in http://wiki.apache.org/couchdb/EntityRelationship using 'One to Many' using separate documents. For example: ( type: "article", id: "a1", desc: "abc1" } ( type: "article", id: "a2", desc: "abc2" } ( type: "tags", tag: "blue", articles: ["a1"] } ( type: "tags", tag: "red", articles: ["a1","a2"] } ( type: "tags", tag: "green", articles: ["a2"] } ( type: "tags", tag: "white", articles: [] } This is a database of articles, where each article can have many tags. The articles array holds the id's for the articles using the tag. So far so good and this all works well. What I'd like to do and hence my question is to query the database for: 1) tags = red or green. result: {[{tag: "red", ..},{tag: "green",..}]} 2) Article with tags red and green. result: {[type: "article", id:"a2"]} These need to specified dynamically with ?key= style, not coded in the view. http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options mentions: {"keys": ["key1", "key2", ...]} and I wonder whether this will do what I want. If not does anyone have any suggestions. I realize I can issue separate view requests and do something like a union on the returned results sets, however I'd much prefer to get CouchDB to do this for me. -- Best regards, Neville Franks, http://www.surfulater.com http://blog.surfulater.com