You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Miles Waller <mi...@gmail.com> on 2017/01/02 20:25:26 UTC

Configuring rewrites in couchdb 1.6.1

Hi,


I have been using couch 1.6.1 successfully for a long period now, but am
trying to set up some rewrites which is a "new" thing for me - and I am
encountering some errors.  I was trying to use the rewrite to just make
some queries for my design doc a little more user-friendly, for example

http://host/user_settings/_design/user_settings/_rewrite/miles/app
<http://couch-uat-quant.orbis.com/user_settings/_design/user_settings/_rewrite/miles/app>

should become

http://host/user_settings/_design/user_settings/_view/settings?key=[“miles”,”app”]&include_docs=true
<http://couch-uat-quant.orbis.com/user_settings/_design/user_settings/_view/settings?key=%5b%E2%80%9Cmiles%E2%80%9D,%E2%80%9Dapp%E2%80%9D%5d&include_docs=true>

First question - is it possible to use rewrites like this, i.e. without any
of the vhost entries.  (I can’t even get a simple example to work (i
wondered if the fact that query.key is a list might have conceivably
tripped it up)…)

Second question - for the above example, I have:

   "*rewrites*": [

       {

           "*method*": "GET",

           "*from*": "/:user/:app",

           "*to*": "/user_settings/_design/user_settings/_view/settings",

           "*query*": {

               "*key*": [

                   ":user",

                   ":app"

               ],

               "*include_docs*": true

           }

       }

   ]



but it just tells me

{"error":"unknown_error","reason":"badarg"}

and I couldn't see any error log entries about it, so I wasn't clear how to
diagnose.


The documentation seems a bit light on rewrites so any advice or pointers
on how I can work out what's going on would be much appreciated!


Many thanks in advance for any help,


Miles