簡體   English   中英

Elasticsearch 重要術語聚合 doc_count 在對相同術語進行匹配短語搜索時與命中不同

[英]Elasticsearch significant terms aggregation doc_count differs from hits when doing a match phrase search for the same term

我正在使用重要術語聚合,它使用以下查詢為我提供了 n 重要術語及其 doc_count 和 bg_count:

{
  "query" : {
      "terms" : {"user_id": ["x"]}
  },
  "aggregations" : {
      "word_cloud" : {
          "significant_terms": { 
              "field" : "transcript.results.alternatives.words.word.keyword",
              "size": 200
          }
      }
  },
  "size": 0
}

如果我采用重要術語聚合返回的術語並對該術語進行匹配短語查詢。 然后,我得到的 hits 值與聚合中的 doc_count 不同。

匹配詞組查詢:

{
  "query": {
    "bool": {
      "must": [
        {
          "match_phrase": {
            "preprocess_data.results.alternatives.transcript": "<term>"
          }
        },
        {
          "match_phrase": {
            "user_id": "x"
          }
        }
      ]
    }
  },
  "from": 0,
  "size": 22
}

字段preprocess_data.results.alternatives.transcript具有以下映射:

{
    "type" : "text",
    "fields" : {
        "keyword" : {
        "type" : "keyword",
        "ignore_above" : 256
        }
    }
}

在進行聚合和匹配短語搜索時,我無法解釋文檔計數的差異。 請幫忙。

這種行為是因為有關doc_count的數據是從索引的所有分片中獲取的,並且在重要術語聚合的情況下,該數據可能是近似的。 引用彈性搜索文檔

有多少文檔包含結果中提供的術語的計數基於從每個分片返回的樣本的總和,因此可能是:

  • 如果某些分片沒有在其頂部樣本中提供給定術語的數字,則為低
  • 考慮背景頻率時很高,因為它可能會計算已刪除文檔中的出現次數

像大多數設計決策一樣,這是權衡的基礎,我們選擇以一些(通常很小的)不准確性為代價來提供快速性能。 但是,下一節中介紹的大小和分片大小設置提供了幫助控制准確度級別的工具

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM