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 = queryDocuments.stream().map(this::convertQueryDocumentToBytes)
.collect(Collectors.toList());
// 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 client.search(searchRequest, RequestOptions.DEFAULT);
}
It seems like the document_type parameter of my request is being set to null:
source={"query":{"percolate":{"document_type":null,"field":"query","documents":[{...}]
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!