Francesco Rosa
Francesco Rosa

Reputation: 11

CouchDB error using startkey&endkey in a key array

Hi guys I'm trying to use the following request:

curl http://localhost:5984/contacts/_design/country/_view/USA?startkey=["USA",{}]&endkey=["USA",{}].

On the following view:

{
"_id": "_design/country",
"_rev": "1-51488ea3931fdca9b9e2de84ef99c4d9",
"language": "javascript",
"views": {
   "USA": {
       "map": "function(doc) {\nif(doc.type == \"contact\") \nemit([doc.country,doc.name] , {name: doc.name, email: doc.email});\n}\n"
   }
 }
 }

and I get this error: [globbing] bad range in column 72

Can you help me?

Upvotes: 0

Views: 125

Answers (2)

Bernhard Gschwantner
Bernhard Gschwantner

Reputation: 1537

Just encode the brackets so that curl doesn't complain. And you would probably want to use a different startkey (without the curly brackets), otherwise you won't get any results. The correct line:

curl http://localhost:5984/contacts/_design/country/_view/USA?startkey=%5B"USA"%5D&endkey=%5B"USA",%7B%7D%5D

Upvotes: 0

Alexis Côté
Alexis Côté

Reputation: 3690

The problem is coming from cUrl I suppose ? Try this :

-g/--globoff
              This  option  switches  off  the "URL globbing parser". When you set this option, you can
              specify URLs that contain the letters {}[] without having them being interpreted by  curl
              itself.  Note  that  these  letters  are not normal legal URL contents but they should be
              encoded according to the URI standard.

Upvotes: 1

Related Questions