I have the following code, that I need to get not null results in some fields, and check values in anothers. (I'm using 'RestHighLevelClient')
But I got this error:
Caused by: ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]]
....
Suppressed: org.elasticsearch.client.ResponseException: method [POST], host [http://192.168.8.101:9200], URI [/_search?typed_keys=true&ignore_unavailable=false&expand_wildcards=open&allow_no_indices=true&scroll=1m&sear .....
{"error":{"root_cause":[{"type":"query_parsing_exception","reason":"[exists] query does not support [boost]
Code:
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
BoolQueryBuilder boolQuery = new BoolQueryBuilder();
boolQuery.must(QueryBuilders.existsQuery("usuarioIntegracao"));
boolQuery.must(QueryBuilders.termsQuery("tabela", "Arquivo", "Mensagem"));
boolQuery.must(QueryBuilders.termQuery("statusTexto", "Erro"));
boolQuery.must(QueryBuilders.rangeQuery("dataEntrada")
.from("now-1d/d")
.timeZone("-03:00"));
searchSourceBuilder.query(boolQuery);
searchSourceBuilder.size(9999);
searchSourceBuilder.timeout(new TimeValue(60, TimeUnit.SECONDS));
searchRequest.source(searchSourceBuilder);
SearchResponse response = client.search(searchRequest, RequestOptions.DEFAULT);
And I have success searching the same on Postman:
{
"size" : 1000,
"sort" : [
{"dataEntrada" : {"order" : "desc"}}
],
"query" : {
"bool":{
"must":[
{"terms":{ "tabela" : ["Arquivo", "Mensagem"] }},
{"term":{ "statusTexto" : "Erro" }},
{"exists" : { "field" : "usuarioIntegracao" }},
{"range" : {
"dataEntrada" : {
"gte" : "now-1d/d",
"lt" : "now/d",
"timeZone" : "-03:00"
}
}}
],
"should":{},
"must_not":{
}
}
}
}