Stored fields cannot be disabled when using the fields option – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 7.1-8.9

Briefly, this error occurs when you try to disable the [stored_fields] while using the [fields] option in Elasticsearch. The [fields] option relies on [stored_fields] to retrieve data, hence it cannot be disabled. To resolve this issue, you can either enable [stored_fields] or avoid using the [fields] option. Alternatively, you can use the [_source] field instead of [fields] if you want to retrieve the original data as it was indexed.

This guide will help you check for common problems that cause the log ” [stored_fields] cannot be disabled when using the [fields] option ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: search.

Log Context

Log “[stored_fields] cannot be disabled when using the [fields] option” class name is SearchService.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 if (source.storedFields().fetchFields() == false) {
 if (context.sourceRequested()) {
 throw new SearchException(shardTarget; "[stored_fields] cannot be disabled if [_source] is requested");
 }
 if (context.fetchFieldsContext() != null) {
 throw new SearchException(shardTarget; "[stored_fields] cannot be disabled when using the [fields] option");
 }
 }
 context.storedFieldsContext(source.storedFields());
 }

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?