elasticsearch-java
elasticsearch-java copied to clipboard
Cannot disable stored fields
Java API client version
8.10.3
Java version
11
Elasticsearch Version
8.9.1
Problem description
I need to disable the retrieval of all stored_fields like _source and _id using this recipe: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-fields.html#disable-stored-fields.
I use the following Java client API:
new SearchRequest.Builder().storedFields("_none_")
However, the Java client always sends "stored_fields":["none"] and subsequently throws an error:
{
"error": {
"root_cause": [
{
"type": "null_pointer_exception",
"reason": """Cannot invoke "java.util.List.size()" because the return value of "org.elasticsearch.search.fetch.StoredFieldsContext.fieldNames()" is null"""
}
],
"type": "null_pointer_exception",
"reason": """Cannot invoke "java.util.List.size()" because the return value of "org.elasticsearch.search.fetch.StoredFieldsContext.fieldNames()" is null"""
},
"status": 500
}
same as https://github.com/elastic/elasticsearch-java/issues/700, https://github.com/elastic/elasticsearch-java/issues/680