sql - 无法对字段 elasticsearch SQL 执行 COUNT 和 GROUP BY 操作
问题描述
我正在使用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] Found 1 problem(s) line 1:57: Field [status] of data type [text] cannot be used for grouping;”
AFAIK 弹性搜索将文本字段的内容标记为倒排索引。因此,像“a room full of brooms”这样的文本将被索引为“a”、“room”、“full”、“of”、“brooms”。
这也取决于所使用的分析仪的类型。 https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-analyzers.html
推荐阅读
- c# - 如何在不同的时间只调用一次不同的方法?
- ios - Socket.io swift客户端自动多次重新连接
- nmea - 类型 5 AIS AIVDM 消息中的第二部分/句子真的很重要吗?
- javascript - TypeScript 报告对象可能是“未定义”,但它不应该
- python - 如何在 Python 中将 POSIX 日期/时间转换为 ISO 并再次返回
- c - scanf("%s", ss+1) 中的“ss+1”是什么意思?
- ios - 如何为 ios 本地通知内容提供自定义辅助功能文本 - UNNotificationContent
- c# - 内存耗尽,应用程序 iis 没有新连接
- kubernetes - Kubernetes 入口设置
- reactjs - 关于 React 的几个问题 - 创建天气应用程序