You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by gaoyong pan <pa...@gmail.com> on 2011/08/23 10:36:52 UTC
first view problem badmatch
I'm trying my first view with url
http://localhost:5984/qq/_design/application/_view/all, the code is,
_id : _design/application
_rev: 8-70c13aeee55e3ba8400f2068f11d9156
views: {
all: {
map: "function(doc) {
emit(doc._id,doc);
}"
}
}
and the error is below, can anyone tell what's the issue here?
{"error":"badmatch","reason":"{ \n all: {\n map: \"function(doc)
{\n emit(doc._id,doc);\n }\"\n }\n}"}
--
Pan
Re: first view problem badmatch
Posted by Sean Copenhaver <se...@gmail.com>.
I believe that 'badmatch' error is an artifact of Erlang. I can't say for
sure but the document may have deserialized fine into Erlang tuples and
such, but when they went to pull out "map" the function couldn't match it
inside the data structure.
Just a guess, but I agree. A lot of times CouchDB error messages are helpful
to the Erlang developer looking at the code and less helpful from the
general user writing JavaScript.
On Tue, Aug 23, 2011 at 8:30 AM, Konstantin Cherkasov <co...@imarto.net>wrote:
> Hello!
>
>
> > If the quotes are missing, Futon will detect a syntax error and save the
> > field value as a string, and CouchDB will complain that it expected a
> > non-string value.
>
>
> Frankly, CouchDB's error messages are in most cases so meaningless that
> you have to guess where is the real problem.
>
> Why "badmatch reason: some crap..." ?
> Why not "invalid syntax in design document" or like "can't parse to valid
> JSON"?
>
>
>
> > .
> > On 23 August 2011 10:36, gaoyong pan <pa...@gmail.com> wrote:
>
> >> I'm trying my first view with url
> >> http://localhost:5984/qq/_design/application/_view/all, the code is,
> >>
> >> _id : _design/application
> >> _rev: 8-70c13aeee55e3ba8400f2068f11d9156
> >> views: {
> >> all: {
> >> map: "function(doc) {
> >> emit(doc._id,doc);
> >> }"
> >> }
> >> }
> >>
> >> and the error is below, can anyone tell what's the issue here?
> >>
> >> {"error":"badmatch","reason":"{ \n all: {\n map: \"function(doc)
> >> {\n emit(doc._id,doc);\n }\"\n }\n}"}
> >> --
> >> Pan
> >>
>
>
>
> --
> Konstantin
>
>
--
“The limits of language are the limits of one's world. “ - Ludwig von
Wittgenstein
"Water is fluid, soft and yielding. But water will wear away rock, which is
rigid and cannot yield. As a rule, whatever is fluid, soft and yielding will
overcome whatever is rigid and hard. This is another paradox: what is soft
is strong." - Lao-Tzu
Re: first view problem badmatch
Posted by Konstantin Cherkasov <co...@imarto.net>.
Hello!
> If the quotes are missing, Futon will detect a syntax error and save the
> field value as a string, and CouchDB will complain that it expected a
> non-string value.
Frankly, CouchDB's error messages are in most cases so meaningless that
you have to guess where is the real problem.
Why "badmatch reason: some crap..." ?
Why not "invalid syntax in design document" or like "can't parse to valid JSON"?
> .
> On 23 August 2011 10:36, gaoyong pan <pa...@gmail.com> wrote:
>> I'm trying my first view with url
>> http://localhost:5984/qq/_design/application/_view/all, the code is,
>>
>> _id : _design/application
>> _rev: 8-70c13aeee55e3ba8400f2068f11d9156
>> views: {
>> all: {
>> map: "function(doc) {
>> emit(doc._id,doc);
>> }"
>> }
>> }
>>
>> and the error is below, can anyone tell what's the issue here?
>>
>> {"error":"badmatch","reason":"{ \n all: {\n map: \"function(doc)
>> {\n emit(doc._id,doc);\n }\"\n }\n}"}
>> --
>> Pan
>>
--
Konstantin
Re: first view problem badmatch
Posted by Victor Nicollet <vn...@runorg.com>.
Hello,
In JSON, you need to place quotes around field names, so the correct value
for the views field should be:
{
"all": {
"map" : "function(doc) { emit(doc._id,doc); }"
}
}
If the quotes are missing, Futon will detect a syntax error and save the
field value as a string, and CouchDB will complain that it expected a
non-string value.
.
On 23 August 2011 10:36, gaoyong pan <pa...@gmail.com> wrote:
> I'm trying my first view with url
> http://localhost:5984/qq/_design/application/_view/all, the code is,
>
> _id : _design/application
> _rev: 8-70c13aeee55e3ba8400f2068f11d9156
> views: {
> all: {
> map: "function(doc) {
> emit(doc._id,doc);
> }"
> }
> }
>
> and the error is below, can anyone tell what's the issue here?
>
> {"error":"badmatch","reason":"{ \n all: {\n map: \"function(doc)
> {\n emit(doc._id,doc);\n }\"\n }\n}"}
> --
> Pan
>