Error parsing json

We are using the REST API to retrieve results from ES, query below:
curl -XGET 'http://:9200/_search?' -d '
{
"query" : {
"bool" : {
"must" : [
{
"field" : { "filename" :
"mozilla-central-linux-debug-1291801653-mochitests-3.gz" }
}
]
}
}
}'

resulting json:
{"_shards":{"total":21,"successful":21,"failed":0},"hits":{"total":1,"max_score":5.6323466,"hits":[{"_index":"logs","_type":"builds","_id":"YuvVewVoQMiANL3ZqpyXcA","_score":5.6323466,
"_source" : { "builds" : {"repo": "mozilla-central", "buildtype":
"debug", "machine": "talos-r3-fed-037", "buildurl":
"http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2",
"platform": "linux", "buildid": "20101208014733", "filename":
"mozilla-central-linux-debug-1291801653-mochitests-3.gz", "revision":
"269083132500"}" } }}]}}

I tried validating the resulting json @
http://jsonformatter.curiousconcept.com/ and it gave the following
errors:
Error:Invalid object closure. [Code 15, Structure 89]
Error:Invalid Braces. [Code 26, Structure 0]

Ditto when I try to parse it using perl module for JSON....
Any ideas on what might be happening here? Is the validator wrong or
something's wrong with ES?

Can you send a sample json that you index? I think that the json that you index is malformed (missing } at the end), and the ES parser is relaxed about that when indexing, but, when it constructs the result, it will fail to be parsed.
On Friday, December 10, 2010 at 3:45 AM, Anurag wrote:

We are using the REST API to retrieve results from ES, query below:
curl -XGET 'http://:9200/_search?' -d '
{
"query" : {
"bool" : {
"must" : [
{
"field" : { "filename" :
"mozilla-central-linux-debug-1291801653-mochitests-3.gz" }
}
]
}
}
}'

resulting json:
{"_shards":{"total":21,"successful":21,"failed":0},"hits":{"total":1,"max_score":5.6323466,"hits":[{"_index":"logs","_type":"builds","_id":"YuvVewVoQMiANL3ZqpyXcA","_score":5.6323466,
"_source" : { "builds" : {"repo": "mozilla-central", "buildtype":
"debug", "machine": "talos-r3-fed-037", "buildurl":
"http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2",
"platform": "linux", "buildid": "20101208014733", "filename":
"mozilla-central-linux-debug-1291801653-mochitests-3.gz", "revision":
"269083132500"}" } }}]}}

I tried validating the resulting json @
http://jsonformatter.curiousconcept.com/ and it gave the following
errors:
Error:Invalid object closure. [Code 15, Structure 89]
Error:Invalid Braces. [Code 26, Structure 0]

Ditto when I try to parse it using perl module for JSON....
Any ideas on what might be happening here? Is the validator wrong or
something's wrong with ES?

thanks shay - my code contained an additional " }.... fixed and ES
now works as advertised :slight_smile:

-anurag

On Thu, Dec 9, 2010 at 7:36 PM, Shay Banon shay.banon@elasticsearch.com wrote:

Can you send a sample json that you index? I think that the json that you
index is malformed (missing } at the end), and the ES parser is relaxed
about that when indexing, but, when it constructs the result, it will fail
to be parsed.

On Friday, December 10, 2010 at 3:45 AM, Anurag wrote:

We are using the REST API to retrieve results from ES, query below:
curl -XGET 'http://:9200/_search?' -d '
{
"query" : {
"bool" : {
""must" : [
{
"field" : { "filename" :
"mozilla-central-linux-debug-1291801653-mochitests-3.gz" }
}
]
}}
}
}'

resulting json:
{"_shards":{"total":21,"successful":21,"failed":0},"hits":{"total":1,"max_score":5.6323466,"hits":[{"_index":"logs","_type":"builds","_id":"YuvVewVoQMiANL3ZqpyXcA","_score":5.6323466,
"_source" : { "builds" : {"repo": "mozilla-central", "buildtype":
"debug", "machine": "talos-r3-fed-037", "buildurl":
"http://stage.mozilla.org/pub/mozilla.org/firefox/tinderbox-builds/mozilla-central-linux-debug/1291801653/firefox-4.0b8pre.en-US.linux-i686.tar.bz2",
"platform": "linux", "buildid": "20101208014733", "filename":
"mozilla-central-linux-debug-1291801653-mochitests-3.gz", "revision":
"269083132500"}" } }}]}}

I tried validating the resulting json @
http://jsonformatter.curiousconcept.com/ and it gave the following
errors:
Error:Invalid object closure. [Code 15, Structure 89]
Error:Invalid Braces. [Code 26, Structure 0]

Ditto when I try to parse it using perl module for JSON....
Any ideas on what might be happening here? Is the validator wrong or
something's wrong with ES?