I have an application which uses java HLRC client fetching results from Elasticsearch cluster. I am facing a peculiar problem in which I am not able to get certain results from Java client side. But the catch is when i am firing the underlying query of Java client in kibana devtools I am getting valid results. I am just not sure what I am doing wrong.
This issue is just happening for a particular field as there are multiple fields and when I fire query on those fields I am getting correct results. So the issue that my whole Java logic is wrong might not be the case, it's just that one specific field which is when queried does not give me desired results.
I am pasting the mapping, the query and the spring boot code here ( Please make in mind the details here are sanitised)
Now I know that the term queries are not analysed that's why I am using the keyword field here. This query when fired in kibana dev tools gives me correct results but the same in java gives me 0 results.
Just to clarify, this is not the HLRC, this is Spring Data which uses the elasticsearch-java-client underneath. The High Level Rest Client was the old version of the elasticsearch-java-client and is now deprecated.
As we do not maintain the Spring Data library for elasticsearch, we're not the ones suited to provide support in this case.
We could try bypassing Spring and checking if it's a client problem, so here's the query using only the elasticsearch-java-client version 8.16.1:
esClient.search(s -> s
.query(q -> q
.bool(b -> b
.must(
TermQuery.of(t -> t
.field("abcField.keyword")
.value("xyz")
.boost(1.0F))._toQuery(),
RangeQuery.of(r -> r
.date(d -> d
.field("timeField")
//...
))._toQuery()
)
.boost(1.0F)
)
)
, Void.class);
Note that adjust_pure_negative is missing, this is an internal parameter that is passed to Lucene in very specific cases.
One other thing I'd check is whether all versions are matching: which server version are you using? Which Kibana version? Which version of the client does Spring Data uses? I'm suspecting it's at least < 8.15 since it's using deprecated parameters in the range query. If there's severe discrepancy between versions it could be the cause of the issue.
Here is some documentation showing how to setup the client.
Hi there,
Just to clarify no we do not use spring data elasticsearch this is just the query builder code. We use HLRC in our code I didn't want to show the whole code that is the reason I just added the query builder code.
I am using kibana version 8.11.3 and the elasticsearch dependency version used is 7.17.6
I am receiving a scrollId ( i don't know why) but no search hits. But the thing is when I am querying with some other field I am receiving search hits but only on this field I am not receiving any search hits.
All in all the response itself is not null just the hits is an empty array
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.