Elasticsearch Java API: query string validation
<p>I'm using Elasticsearch Java API (version 2.1.1) with a <em>Query String Query</em>. The query string is entered by the user and may contain syntax errors. Right now it seems like the query is sent to the server, the response is a <em>shardFailure</em> and an exception is thrown.</p>

<p>Is there an easy way to validate the query in the API before sending it to the server? Right now I'm catching the exception, but it does not feel right to bother the server with these queries.</p>

<p>Query is built like this:</p>

<pre><code>QueryBuilders.queryStringQuery("error)");
</code></pre>

<p>Example response:</p>

<blockquote>
  <p>QueryParsingException[Failed to parse query [error)]]; nested:
  NotSerializableExceptionWrapper[Cannot parse 'error)': Encountered "
  ")" ") "" at line 1, column 5.</p>
</blockquote>

<p>edit:
To be clear:
It is totally ok for the query to contain special characters like brackets or quotes. I just want to check if the user entered a correct search query (e.g. all brackets/quotes in pairs).</p>