You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by "john.tiger" <jo...@gmail.com> on 2012/09/24 02:44:28 UTC

did query change in 1.20 ? [solved - but..]

okay it needed ?key='"jdoe"'  single + plus double quotes - I think this 
needs to be simplified ....

On 09/23/2012 06:03 PM, john.tiger wrote:
> was there a change from ?key=<some value> what is the right syntax ?
>
> /_design/ddoc/_view/getuserdoc?key="jdoe"
>
> => "error":"bad_request","reason":"invalid_json"}
> so does "key"="jdoe", so does key=jdoe
>
> but
> ?{key:"jdoe"} returns all doctypes="user" but not just jdoe as wanted
>
> here's the view:
>
> "views":{
> "getuserdoc":{
> "map":"function(doc) {
> if (doc.doctype == 'user'){
> emit(doc.username, doc);
> }
> }"
> }


Re: did query change in 1.20 ? [solved - but..]

Posted by Chris Daw <cd...@chrisdaw.co.uk>.
It is indeed swallowing quotes - either encase the "search" term in 
single quotes, or escape each double quote character with a backslash.

i.e. use ' " search " ' or \" search \" on the curl command line

Took me a frustrated google search and this post to figure it out!

Re: did query change in 1.20 ? [solved - but..]

Posted by Tim Tisdall <ti...@gmail.com>.
I think a lot of the newer browsers automatically translate the URL
into http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key=%22Meles%20meles%22
when you enter in
http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key="Meles
meles"

In Debian I can run:
curl -X GET "http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key=%22Meles%20meles%22"

and get back:
{"total_rows":5,"offset":4,"rows":[
{"id":"badger","key":"Meles meles","value":11}
]}

If I try the requests without the variable values encoded then I get errors too.

On Mon, Sep 24, 2012 at 3:29 PM, john.tiger <jo...@gmail.com> wrote:
> On 09/24/2012 04:33 AM, Robert Newson wrote:
>>
>> Are you sure it's not your shell that's swallowing the double quotes?
>> ?key="foo" should work.
>>
>> B.
>>
>> On 24 September 2012 10:45, Simon Metson<si...@cloudant.com>  wrote:
>>>
>>> That sounds wrong :) Did your doc.username contain the single quotes?
>>> e.g the double quotes mean a json string and the single quotes should then
>>> be inside that string. How were you making the query? I can hit
>>> http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key="Meles
>>> meles" fine, for instance.
>
>
> I run debian unstable from the terminal window with couchdb 1.20 from the
> unstable repository - is it swallowing quotes ?  I have no idea.  re
> cloudant experience - maybe that's a different couch build
>
> the original json file that was loaded had "username":"jdoe",
>
> as I understand, JSON should have double quotes
>
>
>
>
>
>
>>>
>>>
>>> On Monday, 24 September 2012 at 01:44, john.tiger wrote:
>>>
>>>> okay it needed ?key='"jdoe"' single + plus double quotes - I think this
>>>> needs to be simplified ....
>>>>
>>>> On 09/23/2012 06:03 PM, john.tiger wrote:
>>>>>
>>>>> was there a change from ?key=<some value>  what is the right syntax ?
>>>>>
>>>>> /_design/ddoc/_view/getuserdoc?key="jdoe"
>>>>>
>>>>> =>  "error":"bad_request","reason":"invalid_json"}
>>>>> so does "key"="jdoe", so does key=jdoe
>>>>>
>>>>> but
>>>>> ?{key:"jdoe"} returns all doctypes="user" but not just jdoe as wanted
>>>>>
>>>>> here's the view:
>>>>>
>>>>> "views":{
>>>>> "getuserdoc":{
>>>>> "map":"function(doc) {
>>>>> if (doc.doctype == 'user'){
>>>>> emit(doc.username, doc);
>>>>> }
>>>>> }"
>>>>> }
>>>>>
>>>>
>>>>
>>>
>

Re: did query change in 1.20 ? [solved - but..]

Posted by "john.tiger" <jo...@gmail.com>.
On 09/24/2012 04:33 AM, Robert Newson wrote:
> Are you sure it's not your shell that's swallowing the double quotes?
> ?key="foo" should work.
>
> B.
>
> On 24 September 2012 10:45, Simon Metson<si...@cloudant.com>  wrote:
>> That sounds wrong :) Did your doc.username contain the single quotes?  e.g the double quotes mean a json string and the single quotes should then be inside that string. How were you making the query? I can hit http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key="Meles meles" fine, for instance.

I run debian unstable from the terminal window with couchdb 1.20 from 
the unstable repository - is it swallowing quotes ?  I have no idea.  re 
cloudant experience - maybe that's a different couch build

the original json file that was loaded had "username":"jdoe",

as I understand, JSON should have double quotes





>>
>>
>> On Monday, 24 September 2012 at 01:44, john.tiger wrote:
>>
>>> okay it needed ?key='"jdoe"' single + plus double quotes - I think this
>>> needs to be simplified ....
>>>
>>> On 09/23/2012 06:03 PM, john.tiger wrote:
>>>> was there a change from ?key=<some value>  what is the right syntax ?
>>>>
>>>> /_design/ddoc/_view/getuserdoc?key="jdoe"
>>>>
>>>> =>  "error":"bad_request","reason":"invalid_json"}
>>>> so does "key"="jdoe", so does key=jdoe
>>>>
>>>> but
>>>> ?{key:"jdoe"} returns all doctypes="user" but not just jdoe as wanted
>>>>
>>>> here's the view:
>>>>
>>>> "views":{
>>>> "getuserdoc":{
>>>> "map":"function(doc) {
>>>> if (doc.doctype == 'user'){
>>>> emit(doc.username, doc);
>>>> }
>>>> }"
>>>> }
>>>>
>>>
>>>
>>


Re: did query change in 1.20 ? [solved - but..]

Posted by Robert Newson <rn...@apache.org>.
Are you sure it's not your shell that's swallowing the double quotes?
?key="foo" should work.

B.

On 24 September 2012 10:45, Simon Metson <si...@cloudant.com> wrote:
> That sounds wrong :) Did your doc.username contain the single quotes?  e.g the double quotes mean a json string and the single quotes should then be inside that string. How were you making the query? I can hit http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key="Meles meles" fine, for instance.
>
>
> On Monday, 24 September 2012 at 01:44, john.tiger wrote:
>
>> okay it needed ?key='"jdoe"' single + plus double quotes - I think this
>> needs to be simplified ....
>>
>> On 09/23/2012 06:03 PM, john.tiger wrote:
>> > was there a change from ?key=<some value> what is the right syntax ?
>> >
>> > /_design/ddoc/_view/getuserdoc?key="jdoe"
>> >
>> > => "error":"bad_request","reason":"invalid_json"}
>> > so does "key"="jdoe", so does key=jdoe
>> >
>> > but
>> > ?{key:"jdoe"} returns all doctypes="user" but not just jdoe as wanted
>> >
>> > here's the view:
>> >
>> > "views":{
>> > "getuserdoc":{
>> > "map":"function(doc) {
>> > if (doc.doctype == 'user'){
>> > emit(doc.username, doc);
>> > }
>> > }"
>> > }
>> >
>>
>>
>>
>
>

Re: did query change in 1.20 ? [solved - but..]

Posted by Simon Metson <si...@cloudant.com>.
That sounds wrong :) Did your doc.username contain the single quotes?  e.g the double quotes mean a json string and the single quotes should then be inside that string. How were you making the query? I can hit http://examples.cloudant.com/animaldb/_design/views101/_view/latin_name?key="Meles meles" fine, for instance.


On Monday, 24 September 2012 at 01:44, john.tiger wrote:

> okay it needed ?key='"jdoe"' single + plus double quotes - I think this 
> needs to be simplified ....
> 
> On 09/23/2012 06:03 PM, john.tiger wrote:
> > was there a change from ?key=<some value> what is the right syntax ?
> > 
> > /_design/ddoc/_view/getuserdoc?key="jdoe"
> > 
> > => "error":"bad_request","reason":"invalid_json"}
> > so does "key"="jdoe", so does key=jdoe
> > 
> > but
> > ?{key:"jdoe"} returns all doctypes="user" but not just jdoe as wanted
> > 
> > here's the view:
> > 
> > "views":{
> > "getuserdoc":{
> > "map":"function(doc) {
> > if (doc.doctype == 'user'){
> > emit(doc.username, doc);
> > }
> > }"
> > }
> > 
> 
> 
>