Stored fields cannot be disabled if version is requested – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.9

Briefly, this error occurs when you try to disable `stored_fields` while requesting a version in Elasticsearch. The versioning system in Elasticsearch requires `stored_fields` to track changes in the documents. To resolve this issue, you can either enable `stored_fields` or refrain from requesting a version. If you don’t need versioning, simply remove the version request. If versioning is necessary, ensure `stored_fields` is enabled.

This guide will help you check for common problems that cause the log ” `stored_fields` cannot be disabled if version is requested ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search, version.

Log Context

Log “`stored_fields` cannot be disabled if version is requested” class name is SearchService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 }  if (source.storedFields() != null) {
 if (source.storedFields().fetchFields() == false) {
 if (context.version()) {
 throw new SearchException(shardTarget; "`stored_fields` cannot be disabled if version is requested");
 }
 if (context.sourceRequested()) {
 throw new SearchException(shardTarget; "`stored_fields` cannot be disabled if _source is requested");
 }
 }

 

 [ratemypost]