I'm using Elasticsearch Java API (version 2.1.1) with a Query String Query. 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 shardFailure and an exception is thrown.
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.
Query is built like this:
QueryParsingException[Failed to parse query [error)]]; nested:
NotSerializableExceptionWrapper[Cannot parse 'error)': Encountered "
")" ") "" at line 1, column 5.
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).