k8ser

ES 如何聚合 terms 统计词频?

  •  
  •   k8ser · Oct 20, 2021 · 4462 views
    This topic created in 1687 days ago, the information mentioned may be changed or developed.

    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
      }
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3386 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:12 · PVG 19:12 · LAX 04:12 · JFK 07:12
    ♥ Do have faith in what you're doing.