JSON not well formed?


(timrobertson100) #1

I am trying to use JQuery to issue an ajaxy request to ES, but it
fails. JQuery docs tell me it will 'fail silently' if the JSON is not
well formed, and in firefox, the JSONView plugin is indeed telling me
that the example http://localhost:9200/twitter/user/kimchy?pretty=true
is not well formed. It returns:

{
"_index" : "twitter",
"_type" : "user",
"_id" : "kimchy", "_source" :
{ name: "Shay Banon" }
}

If I change manually the JSON, so that the name becomes "name" it
seems to work fine in

Is this a bug or a desired feature or maybe the legacy of a JSON serializer?

Cheers,
Tim


(Shay Banon) #2

The _source field is the actual JSON document that you indexed. So, if you
indexed it without quotes on field names, it will be returned without
quotes. This is partially my fault, since in some of the examples I don't
quote field names, I need to change all the samples to index quoted JSON
field names.

In terms of elasticsearch, it can parse both quoted and unquoted field
names.

-shay.banon

On Sun, Mar 28, 2010 at 5:00 PM, Tim Robertson timrobertson100@gmail.comwrote:

I am trying to use JQuery to issue an ajaxy request to ES, but it
fails. JQuery docs tell me it will 'fail silently' if the JSON is not
well formed, and in firefox, the JSONView plugin is indeed telling me
that the example http://localhost:9200/twitter/user/kimchy?pretty=true
is not well formed. It returns:

{
"_index" : "twitter",
"_type" : "user",
"_id" : "kimchy", "_source" :
{ name: "Shay Banon" }
}

If I change manually the JSON, so that the name becomes "name" it
seems to work fine in

Is this a bug or a desired feature or maybe the legacy of a JSON
serializer?

Cheers,
Tim


(timrobertson100) #3

Thanks Shay,

When I use quotes on insert it all runs just fine.

On Sun, Mar 28, 2010 at 4:17 PM, Shay Banon
shay.banon@elasticsearch.com wrote:

The _source field is the actual JSON document that you indexed. So, if you
indexed it without quotes on field names, it will be returned without
quotes. This is partially my fault, since in some of the examples I don't
quote field names, I need to change all the samples to index quoted JSON
field names.
In terms of elasticsearch, it can parse both quoted and unquoted field
names.
-shay.banon

On Sun, Mar 28, 2010 at 5:00 PM, Tim Robertson timrobertson100@gmail.com
wrote:

I am trying to use JQuery to issue an ajaxy request to ES, but it
fails. JQuery docs tell me it will 'fail silently' if the JSON is not
well formed, and in firefox, the JSONView plugin is indeed telling me
that the example http://localhost:9200/twitter/user/kimchy?pretty=true
is not well formed. It returns:

{
"_index" : "twitter",
"_type" : "user",
"_id" : "kimchy", "_source" :
{ name: "Shay Banon" }
}

If I change manually the JSON, so that the name becomes "name" it
seems to work fine in

Is this a bug or a desired feature or maybe the legacy of a JSON
serializer?

Cheers,
Tim


(system) #4