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

版本: 6.8-8.9

简而言之,当您尝试在Elasticsearch中使用_source字段进行搜索时会发生此错误。_source字段是一个特殊的字段,包含已索引的原始JSON文档,但它不可搜索。要解决此问题,您可以使用_source字段中的字段进行搜索,或者在映射中为特定字段启用"store"选项,使其可搜索。或者,您可以使用脚本字段从_source字段中提取并返回所需的数据。

日志上下文 #

日志"The _source field is not searchable"的类名是 SourceFieldMapper.java。我们从Elasticsearch源代码中提取了以下内容,供寻求深入背景的人参考:

throw new UnsupportedOperationException("Cannot fetch values for internal field [" + name() + "].");
 }  @Override
 public Query existsQuery(SearchExecutionContext context) {
 throw new QueryShardException(context; "The _source field is not searchable");
 }  @Override
 public Query termQuery(Object value; SearchExecutionContext context) {
 throw new QueryShardException(context; "The _source field is not searchable");