# Java Elastic query not returning results

**URL:** <https://discuss.elastic.co/t/java-elastic-query-not-returning-results/373933>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 31, 2025, 10:53am UTC](https://discuss.elastic.co/t/java-elastic-query-not-returning-results/373933 "2025-01-31T10:53:31Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [January 31, 2025, 11:27am UTC](https://discuss.elastic.co/t/java-elastic-query-not-returning-results/373933/2 "2025-01-31T11:27:27Z")

</div>

Hello!

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:

```java
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](https://discuss.elastic.co/t/what-does-adjust-pure-negative-flag-do/92348).

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](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/getting-started-java.html) showing how to setup the client.

---

_[View the full topic](https://discuss.elastic.co/t/java-elastic-query-not-returning-results/373933)._
