ES 如何聚合 terms 统计词频?

2021-10-20 14:40:31 +08:00
 k8ser

message 字段是 text 且 fielddata=true;想使用 IK 统计索引中所有分词后的 terms 的出现频率。

一 聚合是聚合带有 terms 的 doc_count; 二 虽然能聚合出单条数据 terms,但是需要指定 doc 还是不能聚合出索引内所有 terms;

是不是非常消耗性能 es 不支持这么操作???请大佬指教。

一:
POST message_index/_search
 {
    "size" : 0,  
     "aggs" : {   
        "messages" : {   
              "terms" : {   
              	"size" : 10,
              	"field" : "message"
             }  
        }  
    }
}
二:
GET /message_index/_doc/cFFUnHwB886e1Yi8F6TJ/_termvectors
  {
    "fields" : ["message"],
    "offsets" : true,
    "payloads" : true,
    "positions" : true,
    "term_statistics" : true,
    "field_statistics" : true
  }
1070 次点击
所在节点    Elasticsearch
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/809212

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX