运行报错信息:
ElasticsearchStatusException[Elasticsearch exception [type=search_phase_execution_exception, reason=all shards failed]
]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=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 [starName] in order to load field data by uninverting the inverted index. Note that this can use significant memory.]]; nested: ElasticsearchException[Elasticsearch exception [type=illegal_argument_exception, reason=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 [starName] in order to load field data by uninverting the inverted index. Note that this can use significant memory.]];
分析:聚合时字段 关键字 异常,
到elasticsearch客户端测试:
只用 starName时,发生异常:

在starName基础上加上keyword时,正常:

文章讨论了在使用Elasticsearch进行聚合操作时遇到的错误,指出文本字段不支持聚合和排序,需使用keyword字段或设置fielddata。通过在starName字段上启用keyword,问题得以解决。
3592

被折叠的 条评论
为什么被折叠?



