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

版本: 6.8-7.4

简而言之,当您尝试在未启用 doc_values 的字段上进行结果折叠时,会出现此错误。Elasticsearch 使用 doc_values 进行排序、聚合,以及本例中的折叠操作。要解决此问题,您可以通过更新映射或重新索引数据来在该字段上启用 doc_values。或者,您可以选择在已启用 doc_values 的其他字段上进行折叠。

日志上下文 #

日志 “cannot collapse on field " + field + " without doc\_values” 的类名是 CollapseBuilder.java。 我们从 Elasticsearch 源代码中提取了以下内容,供那些寻求深入上下文的人参考:

throw new SearchContextException(context; "unknown type for collapse field `" + field +
 "`; only keywords and numbers are accepted");
 }  if (fieldType.hasDocValues() == false) {
 throw new SearchContextException(context; "cannot collapse on field `" + field + "` without `doc_values`");
 }
 if (fieldType.indexOptions() == IndexOptions.NONE && (innerHits != null && !innerHits.isEmpty())) {
 throw new SearchContextException(context; "cannot expand `inner_hits` for collapse field `"
 + field + "`; " + "only indexed field can retrieve `inner_hits`");
 }