<p dir="auto">Like most users, I deal with query related parse error messages quite regularly. One thing that has annoyed me for ages is how unreadable these messages are and I was wondering if it would be possible to improve this. Especially with large complicated queries this would be enormously helpful for many users, I imagine.</p>
<p dir="auto">For reference below is an example. The only problem with this query is that I deliberately changed query into querie to trigger a validation error.</p>
<p dir="auto">The message basically tells me that each of my shards failed to parse it. Unless you are running some weird mix of different es versions in one cluster, the parse error is going to be pretty much always identical across shards. So, repeating it is just clutter in this case.  The escaped input makes things hard to read in any case and the fact that the actual problem is listed after this makes it hard to figure out what the problem is.</p>
<p dir="auto">More helpful would if SearchParseException would return a proper json message that would be embedded in the aggregate SearchPhaseExecutionException with a separate field for the original input. Or if that is hard, it would be nice if the message would at least mention the problem before listing the content at least. Also, the from and size attrubute seems to be -1 here. This is probably because the json is actually well formed and there is no syntax problem to report from jackson.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
   &quot;error&quot;: &quot;SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][3]: SearchParseException[[inbot_users_v20][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \&quot;querie\&quot;: {\n    \&quot;term\&quot;: {\n      \&quot;user_id\&quot;: {\n        \&quot;value\&quot;: \&quot;QA0vNmxMevzGf8HCMh8y4A\&quot;\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][3]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][2]: SearchParseException[[inbot_users_v20][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \&quot;querie\&quot;: {\n    \&quot;term\&quot;: {\n      \&quot;user_id\&quot;: {\n        \&quot;value\&quot;: \&quot;QA0vNmxMevzGf8HCMh8y4A\&quot;\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][2]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][1]: SearchParseException[[inbot_users_v20][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \&quot;querie\&quot;: {\n    \&quot;term\&quot;: {\n      \&quot;user_id\&quot;: {\n        \&quot;value\&quot;: \&quot;QA0vNmxMevzGf8HCMh8y4A\&quot;\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][1]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][0]: SearchParseException[[inbot_users_v20][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \&quot;querie\&quot;: {\n    \&quot;term\&quot;: {\n      \&quot;user_id\&quot;: {\n        \&quot;value\&quot;: \&quot;QA0vNmxMevzGf8HCMh8y4A\&quot;\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][0]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][4]: SearchParseException[[inbot_users_v20][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \&quot;querie\&quot;: {\n    \&quot;term\&quot;: {\n      \&quot;user_id\&quot;: {\n        \&quot;value\&quot;: \&quot;QA0vNmxMevzGf8HCMh8y4A\&quot;\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][4]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }]&quot;,
   &quot;status&quot;: 400
}"><pre class="notranslate"><code class="notranslate">{
   "error": "SearchPhaseExecutionException[Failed to execute phase [query], all shards failed; shardFailures {[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][3]: SearchParseException[[inbot_users_v20][3]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"querie\": {\n    \"term\": {\n      \"user_id\": {\n        \"value\": \"QA0vNmxMevzGf8HCMh8y4A\"\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][3]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][2]: SearchParseException[[inbot_users_v20][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"querie\": {\n    \"term\": {\n      \"user_id\": {\n        \"value\": \"QA0vNmxMevzGf8HCMh8y4A\"\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][2]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][1]: SearchParseException[[inbot_users_v20][1]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"querie\": {\n    \"term\": {\n      \"user_id\": {\n        \"value\": \"QA0vNmxMevzGf8HCMh8y4A\"\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][1]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][0]: SearchParseException[[inbot_users_v20][0]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"querie\": {\n    \"term\": {\n      \"user_id\": {\n        \"value\": \"QA0vNmxMevzGf8HCMh8y4A\"\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][0]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }{[XtMbDAz6TBqSKZAUL5zfhA][inbot_users_v20][4]: SearchParseException[[inbot_users_v20][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n  \"querie\": {\n    \"term\": {\n      \"user_id\": {\n        \"value\": \"QA0vNmxMevzGf8HCMh8y4A\"\n      }\n    }\n  }\n}\n]]]; nested: SearchParseException[[inbot_users_v20][4]: from[-1],size[-1]: Parse Failure [No parser for element [querie]]]; }]",
   "status": 400
}
</code></pre></div>
<p dir="auto">Errors returned by the REST API are not easily human readable due to the way the data is stored in the <code class="notranslate">error</code> property.<br>
Eg. <a href="https://gist.github.com/missinglink/e3cb9b127ae00e8c561c">https://gist.github.com/missinglink/e3cb9b127ae00e8c561c</a></p>
<p dir="auto">You can 'prettify' the results, but it is still un-readable.<br>
Eg. <a href="https://gist.github.com/pecke01/5956684">https://gist.github.com/pecke01/5956684</a></p>
<p dir="auto">Note: (this specific error was caused by invalid syntax, the outer curly brackets were missing)</p>
<p dir="auto">This issue makes it difficult for beginners to understand syntax errors and for advanced users to debug quickly when they make silly errors.</p>
<p dir="auto">Ideally usage of <code class="notranslate">?pretty=1</code> would return "developer friendly" messages.</p>
<p dir="auto">Any thoughts / suggestions? Maybe there is a tool which may help?</p>