Is there an equivalent of the query_string for the ES Java API 5.4, as it look like that queryString is unavailable in this version?
Also there isn't anything descriptive about the queryStringQuery in the documentation of the Java API.
I'm passing as an argument exactly what I'd write in case of using -curl to the method queryStringQuery, and it results in SearchPhaseExecutionException.
My aim is to get all the values of a certain field (crash_case in this case). For that I'm doing a query_string query and then perform an aggregation, and get the keys from the buckets.
Here is the -curl command that works just fine:
{
"query" : { "query_string" : {"query" : "*"} },
"aggs" : {
"tags" : { "terms" : {"field" : "crash_case.keyword"} }
}
}
And this is the java code that should behave in a similar fashion in my opinion:
SearchResponse response = client.prepareSearch("closed-cases")
.setQuery(QueryBuilders.queryStringQuery("\"query\" : \"*\""))
.addAggregation(AggregationBuilders.terms("check").field("crash_case.keyword"))
.execute()
.actionGet();