# Include\_lower / include\_upper is deprecated?

**URL:** <https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295>\
**Category:** Elasticsearch\
**Created:** [January 16, 2025, 9:04pm UTC](https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295 "2025-01-16T21:04:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jamshid](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jamshid](https://discuss.elastic.co/u/Jamshid)\
**Post date:** [January 16, 2025, 9:04pm UTC](https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295/1 "2025-01-16T21:04:10Z")

</div>

After upgrading to elasticsearch 8.17 it seems I started seeing this deprecation log.

`],[299 Elasticsearch-8.17.0-2b6a7fed44faa321997703718f07ee0420804b41 "Deprecated field [include_upper] used, this field is unused and will be removed entirely"]`

```auto
172.42.0.18 <172>2025-01-16T18:37:17,585 WARN [Puller|] RestClient: request [POST http://172.42.0.12:9200/myindex/_search?typed_keys=true&max_concurrent_shard_requests=5&allow_partial_search_results=false&search_type=query_then_fetch&batched_reduce_size=512] returned 4 warnings: [299 Elasticsearch-8.17.0-2b6a7fed44faa321997703718f07ee0420804b41 "Deprecated field [from] used, this field is unused and will be removed entirely"],[299 Elasticsearch-8.17.0-2b6a7fed44faa321997703718f07ee0420804b41 "Deprecated field [to] used, this field is unused and will be removed entirely"],[299 Elasticsearch-8.17.0-2b6a7fed44faa321997703718f07ee0420804b41 "Deprecated field [include_lower] used, this field is unused and will be removed entirely"],[299 Elasticsearch-8.17.0-2b6a7fed44faa321997703718f07ee0420804b41 "Deprecated field [include_upper] used, this field is unused and will be removed entirely"]

```

The app is using the Java High Level REST Client built with compatibility mode.

```auto
new RestHighLevelClientBuilder(this.lowLevelClient)
            .setApiCompatibilityMode(this.getVersion().after(Version.V_7_11_0))

```

I search elasticsearch docs for "include\_lower" expecting to find some hit about the deprecation and what to use instead, but results are pretty useless:

> **[Elastic.co Search](https://search.elastic.co/?q=%22include_lower%22&location%5B0%5D=Documentation&product%5B0%5D=Elasticsearch)**
>
> Search all of Elastic.co.

 ![Screenshot 2025-01-16 at 3.01.56 PM](https://us1.discourse-cdn.com/elastic/original/3X/7/a/7ac2c38a963d6ad6b4cb50d8c80472a59d185de4.jpeg)

---

<div class="post-metadata">

**Author:** ![Jamshid](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jamshid](https://discuss.elastic.co/u/Jamshid)\
**Post date:** [January 16, 2025, 9:36pm UTC](https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295/2 "2025-01-16T21:36:56Z")

</div>

A bit more searching through the release notes and found:

> **[Migrating to 8.16 | Elasticsearch Guide \[8.17\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.16.html#deprecations_816_rest_api)**

**Details**  
Range query will not longer accept `to`, `from`, `include_lower`, and `include_upper` parameters.

**Impact**  
Instead use `gt`, `gte`, `lt` and `lte` parameters.

---

<div class="post-metadata">

**Author:** ![Jamshid](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jamshid](https://discuss.elastic.co/u/Jamshid)\
**Post date:** [February 3, 2025, 10:19pm UTC](https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295/3 "2025-02-03T22:19:17Z")

</div>

Of course it's never that simple. I'm using the Java `elasticsearch-rest-high-level-client` 7.17.14 with elasticsearch 8 "compatibility mode" enabled:

> **[Java High Level REST Client | Java REST Client \[7.17\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high.html)**

Yes I know this SDK was deprecated for the Java API Client but that requires a lot of application code rewrite.

I thought changing application code currently using RangeQueryBuilder.from() to use RangeQueryBuilder.lte() would fix this deprecation warning but nope!

The "new" methods like `gt()` simply call the old, deprecated methods like `from()`!. Why? Anyone know of a workaround?

Since elasticsearch 8 knows the client and version seems it should not log this deprecation. Note the java methods themselves were never actually declared `@deprecated`.

```auto
- .should(QueryBuilders.rangeQuery(FIELD_NAME).from(keyMarker).includeLower(false))
+ .should(QueryBuilders.rangeQuery(FIELD_NAME).gt(keyMarker))

```

RangeQueryBuilder.java uses

```auto
    public RangeQueryBuilder from(Object from) {
        return from(from, this.includeLower);
    }
    ...
    public RangeQueryBuilder gt(Object from) {
        return from(from, false);
    }

```

---

<div class="post-metadata">

**Author:** ![Jamshid](https://avatars.discourse-cdn.com/v4/letter/j/ecd19e/32.png) [@Jamshid](https://discuss.elastic.co/u/Jamshid)\
**Post date:** [February 3, 2025, 10:36pm UTC](https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295/4 "2025-02-03T22:36:24Z")

</div>

FWIW I'm asking in [Range queries logs inconsistent with documentation · Issue #48538 · elastic/elasticsearch · GitHub](https://github.com/elastic/elasticsearch/issues/48538#issuecomment-2632330987) if there's any chance for a fix in the SDK or server for this.

> Any chance of either making a Java REST Client SDK 7.17 release with this fix? Or if that's not going to happen, making the next elasticearch 8.17 release not log the deprecation warning when it sees that the client is **Elastic's own** 7.17 SDK?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 3, 2025, 10:37pm UTC](https://discuss.elastic.co/t/include-lower-include-upper-is-deprecated/373295/5 "2025-03-03T22:37:15Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
