Error handling in rest api

Hi,
I am trying out the elasticsearch javascript connection driver. It is
working fine, but I am facing a problem with the error handling. To me it
seems to be an elasticsearch rest api problem.

I am creating a request with the following body:
{
"facets": {},
"query": {
"simple_query_string": {
"query": "test",
"fields": ["_all"],
"analyzer": "snowball"
}
}
}

This is working fine with elasticsearch 0.90.9+, however as expected, it
does not work with 0.90.7. This is all logical since it is something that
is introduced in 0.90.9. The problem is the error handling. In the response
I get the following message:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query],
all shards failed; shardFailures {[8ClRn1lKRdeaawyrWGTUtw][myimages][0]:
SearchParseException[[myimages][0]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"facets":{},"query":{"simple_query_string":{"query":"test","fields":["_all"],"analyzer":"snowball"}}}]]];
nested: QueryParsingException[[myimages] No query registered for
[simple_query_string]]; }{[8ClRn1lKRdeaawyrWGTUtw][mymusic][0]:
SearchParseException[[mymusic][0]: from[-1],size[-1]: Parse Failure [Failed
to parse source
[{"facets":{},"query":{"simple_query_string":{"query":"test","fields":["_all"],"analyzer":"snowball"}}}]]];
nested: QueryParsingException[[mymusic] No query registered for
[simple_query_string]]; }{[8ClRn1lKRdeaawyrWGTUtw][kibana-int][0]:
SearchParseException[[kibana-int][0]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"facets":{},"query":{"simple_query_string":{"query":"test","fields":["_all"],"analyzer":"snowball"}}}]]];
nested: QueryParsingException[[kibana-int] No query registered for
[simple_query_string]]; }]",
"status": 400
}

The response using the javascript driver (in the browser) is a
ConnectionFailure. I would like to obtain the message
"QueryParsingException[[kibana-int] No query registered for
[simple_query_string]]" out of this, that would really help. This is doable
using the elasticsearch logs but I cannot present this message using
javascript to the client.

Reproduction of this error is easy with my plugin at
http://www.gridshore.nl/esgui with a local elasticsearch running on 0.90.7

Anybody has an idea how to improve this?

thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/43180d10-d272-4750-ad4d-68dee4f55306%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Forgot to mention to reproduce in the plugin, go to the search tab, enter a
term to search on and press the search button. You won't see a problem in
the screen, but you will see errors in the console. The messages I have
shown were obtained using charles (a proxy).

Op zondag 12 januari 2014 15:51:29 UTC+1 schreef Jettro Coenradie:

Hi,
I am trying out the elasticsearch javascript connection driver. It is
working fine, but I am facing a problem with the error handling. To me it
seems to be an elasticsearch rest api problem.

I am creating a request with the following body:
{
"facets": {},
"query": {
"simple_query_string": {
"query": "test",
"fields": ["_all"],
"analyzer": "snowball"
}
}
}

This is working fine with elasticsearch 0.90.9+, however as expected, it
does not work with 0.90.7. This is all logical since it is something that
is introduced in 0.90.9. The problem is the error handling. In the response
I get the following message:

{
"error": "SearchPhaseExecutionException[Failed to execute phase [query],
all shards failed; shardFailures {[8ClRn1lKRdeaawyrWGTUtw][myimages][0]:
SearchParseException[[myimages][0]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"facets":{},"query":{"simple_query_string":{"query":"test","fields":["_all"],"analyzer":"snowball"}}}]]];
nested: QueryParsingException[[myimages] No query registered for
[simple_query_string]]; }{[8ClRn1lKRdeaawyrWGTUtw][mymusic][0]:
SearchParseException[[mymusic][0]: from[-1],size[-1]: Parse Failure [Failed
to parse source
[{"facets":{},"query":{"simple_query_string":{"query":"test","fields":["_all"],"analyzer":"snowball"}}}]]];
nested: QueryParsingException[[mymusic] No query registered for
[simple_query_string]]; }{[8ClRn1lKRdeaawyrWGTUtw][kibana-int][0]:
SearchParseException[[kibana-int][0]: from[-1],size[-1]: Parse Failure
[Failed to parse source
[{"facets":{},"query":{"simple_query_string":{"query":"test","fields":["_all"],"analyzer":"snowball"}}}]]];
nested: QueryParsingException[[kibana-int] No query registered for
[simple_query_string]]; }]",
"status": 400
}

The response using the javascript driver (in the browser) is a
ConnectionFailure. I would like to obtain the message
"QueryParsingException[[kibana-int] No query registered for
[simple_query_string]]" out of this, that would really help. This is doable
using the elasticsearch logs but I cannot present this message using
javascript to the client.

Reproduction of this error is easy with my plugin at
Elasticsearch gui with a local elasticsearch running on 0.90.7

Anybody has an idea how to improve this?

thanks

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/e74eb8aa-839e-46d0-8d38-ce2a5182a863%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

The reason why you receive a SearchPhaseExecutionException and many
SearchParseExceptions is that your query is parsed at each shard and causes
an error at that deeper level. ES wraps up the shards responses into a
SearchPhaseExecutionException
which is passed back to the client.

In most cases, all shards respond with same errors, but that is not always
the case.

This certainly can be improved regarding the JSON formatting by a patch to
ES so the REST action tries to parse error response from shards.

Another possibility would be processing the shards exceptions and just
returning a short SearchPhaseExecutionException message saying something
like "no query registered for ..." if all shard errors match.

In general, I would simply rely on the REST response codes (here: 400)
which signals "bad request" and ignore the ES error messages since they are
fluctuating.

Jörg

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEgmRHYXe6-9XaDrHjDPeb2Xq7%3D8bumetxAFcXbFHiB3Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.