我正在使用 Elasticsearch SQL 从 canvas [Kibana] 中的 elasticsearch 索引中获取数据以进行可视化。
这是我的 ESSQL 查询:SELECT COUNT(status), status FROM "indexName" GROUP BY status
注意:字段状态的类型为文本
当我尝试执行此查询时,发生以下错误:
[essql] > Unexpected error from Elasticsearch:
[verification_exception] Found 1 problem(s) line 1:57: Field [status]
of data type [text] cannot be used for grouping;
No keyword/multi-field defined exact matches for [status]; define one
or use MATCH/QUERY instead
提前致谢。
最佳答案
我认为这是因为不允许您对文本字段进行计数或执行聚合。错误说明中也提到了同样的问题
“[verification_exception]在第1:57行发现1个问题:字段[状态]
类型为[文本]的数据不能用于分组;”
AFAIK flex 搜索将文本字段的内容标记为反向索引。因此,诸如“满是扫帚的房间”之类的文本将被索引为“一”,“房间”,“满”,“有”,“扫帚”。
这将取决于所用分析仪的类型。
https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html
关于sql - 无法对字段Elasticsearch SQL执行COUNT和GROUP BY操作,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/61074290/