# RestHighLevelClient, warning "Deprecated field \[type\] used"

**URL:** <https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [January 26, 2024, 10:11am UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870 "2024-01-26T10:11:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![antoinelefloch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antoinelefloch/32/24577_2.png) [@antoinelefloch](https://discuss.elastic.co/u/antoinelefloch)\
**Post date:** [January 26, 2024, 10:11am UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870/1 "2024-01-26T10:11:46Z")

</div>

Hello,

I am using RestHighLevelClient  
(elasticsearch-rest-high-level-client-7.17.16.jar)

and I get a warning from our 7.17.13 server

> Warning: 299 Elasticsearch-7.17.13-2b211dbb8bfdecaf7f5b44d356bdfe54b1050c13 "Deprecated field [type] used, this field is unused and will be removed entirely"

This is filling up my stack logs. Is there a way to get rid off this warning.  
What are my options ?  
I guess using

> **[Elasticsearch Java API Client \[7.17\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.17/index.html)**

will solve the issue ?  
Thank you

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [January 26, 2024, 10:33am UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870/2 "2024-01-26T10:33:36Z")

</div>

The log message says "this field is unused and will be removed entirely". So your best option is most certainly to stop using this `type` field!

---

<div class="post-metadata">

**Author:** ![antoinelefloch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antoinelefloch/32/24577_2.png) [@antoinelefloch](https://discuss.elastic.co/u/antoinelefloch)\
**Post date:** [January 27, 2024, 11:35pm UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870/3 "2024-01-27T23:35:30Z")

</div>

Hello,  
the "type" field it is complaining about, is the one from the GeoBoundingBoxQueryBuilder 7.17.16 class.

[https://javadoc.io/doc/org.elasticsearch/elasticsearch/7.17.16/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.html](https://javadoc.io/doc/org.elasticsearch/elasticsearch/7.17.16/org/elasticsearch/index/query/GeoBoundingBoxQueryBuilder.html)

```auto
{
  "geo_bounding_box" : {
    "location" : {
      "top_left" : [
        -0.5,
        45.0
      ],
      "bottom_right" : [
        0.5,
        44.2
      ]
    },
    "validation_method" : "STRICT",
    "type" : "MEMORY",
    "ignore_unmapped" : true,
    "boost" : 1.0
  }
}

```

Here is some code that reproduce the issue:

```auto
public class MyMain {
    public static void main(String arg[]) {
        final CredentialsProvider credentialProvider = new BasicCredentialsProvider();
        credentialProvider.setCredentials(
                AuthScope.ANY,
                new UsernamePasswordCredentials(
                        "my un",
                        "my_pw"
                ));

        RestHighLevelClient highLevelClient = new RestHighLevelClient(
                RestClient.builder(new HttpHost("my_server_address", 9200, "http"))
                        .setHttpClientConfigCallback(httpAsyncClientBuilder -> {
                            httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialProvider);
                            return httpAsyncClientBuilder;
                        })
        );

        // Calling API synchronously.
        try {
            CountRequest request = new CountRequest(new String[]{"pj-search-request-alias-1-dev"});

            SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();

            final GeoBoundingBoxQueryBuilder geoBuilder = QueryBuilders
                    .geoBoundingBoxQuery("location")
                    .setCorners(45.0, -0.5, 44.2, 0.5)
                    .ignoreUnmapped(true);

            QueryBuilder queryBuilder = QueryBuilders
                    .boolQuery()
                    .should(geoBuilder);

            searchSourceBuilder.query(queryBuilder);
            request.source(searchSourceBuilder);

            CountResponse count = highLevelClient.count(request, RequestOptions.DEFAULT);
            System.out.println(" ******* done" + count);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

```

```auto
    <dependencies>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
            <version>7.17.16</version>
        </dependency>

        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>7.17.16</version>
        </dependency>

    </dependencies>

```

---

<div class="post-metadata">

**Author:** ![swallez](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/swallez/32/11972_2.png) [@swallez](https://discuss.elastic.co/u/swallez)\
**Post date:** [January 29, 2024, 10:22am UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870/4 "2024-01-29T10:22:44Z")

</div>

Thanks for the additional details. By default the `RestHighLevelClient` will send `type = "MEMORY"` and the server will issue a warning. And unfortunately setting `type` to `null` will throw an exception.

There are two options:

- use the Java API client for this request. You don't have to migrate your entire application: Java API client and HLRC can [smoothly work side by side with the same low level client](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/7.17/migrate-hlrc.html).
- disable [deprecation warnings on the server](https://discuss.elastic.co/t/turn-off-es-deprecation-logs-dynamically/221948). But this will hide all deprecation warnings, which may be valuable information.

---

<div class="post-metadata">

**Author:** ![antoinelefloch](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/antoinelefloch/32/24577_2.png) [@antoinelefloch](https://discuss.elastic.co/u/antoinelefloch)\
**Post date:** [January 29, 2024, 10:47am UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870/5 "2024-01-29T10:47:59Z")

</div>

OK, thanks for the reply, will disable warnings through config for now.

---

<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:** [February 26, 2024, 10:48am UTC](https://discuss.elastic.co/t/resthighlevelclient-warning-deprecated-field-type-used/351870/6 "2024-02-26T10:48:16Z")

</div>

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