版本: 6.8-7.15
简而言之,当在一个非keyword或text类型的字段上使用正则表达式(regexp)查询时,就会出现这个错误。Elasticsearch只支持在keyword和text字段上使用regexp查询。要解决这个问题,你可以将字段类型更改为keyword或text,或者使用与当前字段类型兼容的其他查询类型。另一个解决方案是创建一个keyword或text类型的multi-field,并在其上使用regexp查询。
日志上下文 #
日志"Can only use regexp queries on keyword and text fields - not on [“的类名是 MappedFieldType.java。我们从Elasticsearch源代码中提取了以下内容,供那些寻求深入了解上下文的人参考:
+ "] which is of type [" + typeName() + "]");
} public Query regexpQuery(String value; int syntaxFlags; int matchFlags; int maxDeterminizedStates;
@Nullable MultiTermQuery.RewriteMethod method; SearchExecutionContext context) {
throw new QueryShardException(context; "Can only use regexp queries on keyword and text fields - not on [" + name
+ "] which is of type [" + typeName() + "]");
} public Query existsQuery(SearchExecutionContext context) {
if (hasDocValues()) {





