📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

版本: 7.1-8.9

简要来说,当您在 Elasticsearch 中尝试在使用 [fields] 选项的同时禁用 [stored_fields] 时,会出现此错误。[fields] 选项依赖于 [stored_fields] 来检索数据,因此无法禁用它。要解决此问题,您可以启用 [stored_fields] 或避免使用 [fields] 选项。另外,如果您想检索索引时的原始数据,可以使用 [_source] 字段代替 [fields]。

日志上下文 #

日志"[stored_fields] cannot be disabled when using the [fields] option"的类名是 SearchService.java. 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入理解的人参考:

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());
 }