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 505F1760B for ; Wed, 7 Dec 2011 20:40:36 +0000 (UTC) Received: (qmail 69833 invoked by uid 500); 7 Dec 2011 20:40:34 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 69791 invoked by uid 500); 7 Dec 2011 20:40:34 -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 69782 invoked by uid 99); 7 Dec 2011 20:40:34 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Dec 2011 20:40:34 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [74.82.40.36] (HELO calftrail.com) (74.82.40.36) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 07 Dec 2011 20:40:25 +0000 Received: from ::ffff:96.39.146.57 ([96.39.146.57]) by calftrail.com for ; Wed, 7 Dec 2011 12:40:03 -0800 From: Nathan Vander Wilt Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Subject: Rewrite not able to combine multiple path parts into single query value? Date: Wed, 7 Dec 2011 12:40:05 -0800 Message-Id: To: user@couchdb.apache.org Mime-Version: 1.0 (Apple Message framework v1251.1) X-Mailer: Apple Mail (2.1251.1) X-Virus-Checked: Checked by ClamAV on apache.org I'm trying to spin up a very simple blog engine in CouchDB. Each post = has a "path" property like "2010/11/building_ppc_couchdb" that I'd like = to use via a rewrite rule as follows: { "from": "/blog/*", "to": "_list/posts/by_path", "query": { "include_docs": "true", "key": "*" } } However, the asterisk in the rewrite rule seems to only capture the = first path component in the logs I see: /dev/_design/glob/_rewrite/blog/2010/11/building_ppc_couchdb ...get = rewritten to: /dev/_design/glob/_list/posts/by_path?key=3D%222010%22&include_docs=3Dtrue= So I thought maybe I'll just set up four or five rules like: { "from": "/blog/:path1/:path2/:path3/", "to": "_list/posts/by_path", "query": { "include_docs": "true", "key": ":path1/:path2/:path3" } } ...to handle anywhere from one to several path components. But in that = case the variables in "key" don't get rewritten: = /dev/_design/glob/_list/posts/by_path?key=3D%22%3Apath1%2F%3Apath2%2F%3Apa= th3%22&include_docs=3Dtrue&path1=3D2010&path2=3D11&path3=3Dbuilding_ppc_co= uchdb The rewriter logic seems frustratingly fickle; are both of the above = examples behaving as intended? The wiki documentation is pretty clear as = far as matching goes, but fuzzy as far as how the subsequent templating = into the "to" and "query" values is supposed to work. The only way I've been able to figure out is to tweak my view function = to .split("/") the path before emitting it, and then set up a handful of = rules like: { "from": "/blog/:path1/", "to": "_list/posts/by_path", "query": { "include_docs": "true", "key": [":path1"] } }, { "from": "/blog/:path1/:path2/", "to": "_list/posts/by_path", "query": { "include_docs": "true", "key": [":path1",":path2"] } }, { "from": "/blog/:path1/:path2/:path3/", "to": "_list/posts/by_path", "query": { "include_docs": "true", "key": [":path1",":path2",":path3"] } }, { "from": "/blog/:path1/:path2/:path3/:path4/", "to": "_list/posts/by_path", "query": { "include_docs": "true", "key": [":path1",":path2",":path3",":path4"] } } This works, but is there a better way to accomplish this general idea? thanks, -natevw=