Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [content.resource.name] in order to load field data by uninverting the inverted index.
在 es 中,对词进行查询、聚合的时候,需要使用 .keyword。 否则会报错:
Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [content.resource.name] in order to load field data by uninverting the inverted index.
使用 keyword 查询如下:
什么是 keyword
总结: 使用 term 进行精确词的匹配的时候,必须要用 keyword