Elasticsearch 统计热词
时间: 2023-12-20 17:50:44 浏览: 27
Elasticsearch 可以使用 "terms aggregation" 来统计热词。
首先,需要确定您要统计的字段。假设您要统计 "text" 字段中的热词,您可以执行以下查询:
```
GET my_index/_search
{
"size": 0,
"aggs": {
"hot_words": {
"terms": {
"field": "text"
}
}
}
}
```
这个查询将返回 "text" 字段中的热词,并以降序排列。您可以使用 "size" 参数控制返回的热词数量。
例如:
```
GET my_index/_search
{
"size": 0,
"aggs": {
"hot_words": {
"terms": {
"field": "text",
"size": 10
}
}
}
}
```
这将返回 "text" 字段中的前 10 个热词。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)