我刚打酱油去了,不好意思

es是否可以对一组词按出现在次数进行排序

Elasticsearch | 作者 benero | 发布于2016年08月26日 | 阅读数:5513

这个查询是找出匹配记录的TOP5的词,但是否可以只统计固定的某组词的词频

类似 :select word, count(*) as cnt from table_name where word in ('a', 'b', 'c', 'd') group by word order by cnt desc LIMIT 10


​{

"query": {
"bool": {
"must": [
{"terms": {"content": ["word"]}}
]
}
},
"aggs": {
"top5": {
"buckets": { "field" : "content","size":5 }
}
}
}


已邀请:

medcl - 今晚打老虎。

赞同来自:

你给出的查询貌似就可以啊

要回复问题请先登录注册