I want to validate a query before saving it for use later. I see ES has a validate API but it cant see a way to use it with the Java api.
Is there a way to validate ES queries using the java api?
Maybe I could just run the query before saving it?
So after looking at the elastic search source code I came up with this solution.
public ActionFuture<ValidateQueryResponse> validateAsync(QueryBuilder query, String[] indices) {
final ValidateQueryRequest request = new ValidateQueryRequest();
request.indices(indices);
request.source(query.buildAsBytes());
return esClient.admin().indices().validateQuery(request);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With