Percolate Query Issues after Upgrading to Elasticsearch 8.6.2 with REST High-Level Client 7.17.9

Hello Elasticsearch community,

I'm currently experiencing an issue with the Percolate Query after upgrading my Elasticsearch version to 8.6.2. I'm still using the REST High-Level Client 7.17.9.

Here's the exception I'm getting: "Elasticsearch exception [type=x_content_parse_exception, reason=[1:40] [percolate] document_type doesn't support values of type: VALUE_NULL]"

This exception is raised when running the following piece of code:

public SearchResponse percolate(String percolatorIndex, List<?> queryDocuments) throws IOException {
    // get a list of documents in bytes
    final List<BytesReference> documentBytes =

    // create the percolator query
    final PercolateQueryBuilder percolateQueryBuilder = new PercolateQueryBuilder(QUERY_FIELD,
            documentBytes, XContentType.JSON);

    // create the search request
    final SearchRequest searchRequest = new SearchRequest(percolatorIndex)
            .source(new SearchSourceBuilder().query(percolateQueryBuilder));

    // call the search
    return, RequestOptions.DEFAULT);

It seems like the document_type parameter of my request is being set to null:

However, I can't figure out where to change this. I've been going through the code and haven't found any place where the document_type value is set.

I should also note that this issue arose after I upgraded my Elasticsearch version to 8.6.2. Before the upgrade, this code was working fine.

Does anyone have any ideas or suggestions on how to resolve this? I don't understand what is the use of this document_type fields, and why it is not set to json instead of null.

Thanks in advance for your help!

I think you need to upgrade to the new Java Client version 8.6.2 (8.8.1 should work as well and is better).

I understand that this could be a solution but it wil take us a lot of time. I read that "The High Level Client version 7.16 and higher can communicate with Elasticsearch version 8.x after enabling API compatibility mode" ( Compatibility | Java REST Client [7.17] | Elastic) so in theory i could make it work with the client no ?

Yes it should be but in general, I'd try to use the same version on both sides.

If you can't, then using this mode should work. If it does not for this API, I'm fearing that could be a bug. May be first upgrade to 7.17.10 although I don't know if this will fix the problem.

@swallez might know...

1 Like

Document types have been deprecated in version 8, and should ignore them. Except that it still rejects a null value for this ignored setting.

Try using new PercolateQueryBuilder(QUERY_FIELD, "dummy_type", documentBytes, ContentType.JSON)

1 Like

Thank you very much, it has worked for me!

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