RestHighLevelClient, warning "Deprecated field [type] used"

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

will solve the issue ?
Thank you

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!

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

{
  "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:

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);
        }
    }
}
    <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>

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:

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

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