elasticsearch-java icon indicating copy to clipboard operation
elasticsearch-java copied to clipboard

Cannot disable stored fields

Open valasatava opened this issue 1 year ago • 1 comments

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
}

valasatava avatar Nov 07 '23 05:11 valasatava

same as https://github.com/elastic/elasticsearch-java/issues/700, https://github.com/elastic/elasticsearch-java/issues/680

l-trotta avatar Apr 24 '24 10:04 l-trotta