簡體   English   中英

如何在Elasticsearch中按值數組查詢/過濾精確計數?

[英]How can I query/filter an exact count by an array of values in Elasticsearch?

我有這些文件:

{"title": "aa","cast": ["a","b","c","a"]}
{"title": "bb","cast": ["a","b","c","b"]}
{"title": "cc","cast": ["a","b","c","c"]}

我使用刻面得到結果。

facets": {
      "cast_result": {
         "_type": "terms",
         "missing": 0,
         "total": 9,
         "other": 0,
         "terms": [
            {
               "term": "c",
               "count": 3
            },
            {
               "term": "b",
               "count": 3
            },
            {
               "term": "a",
               "count": 3
            }
         ]
      }
  }
}

但我希望結果“ a”的數量為四,因為在實際文檔中“ a”的頻率為四。“ b”和“ c”也類似於“ a”。

創建索引

詢問

期限總和就是答案

但是我發現一個問題,當分片的數量大於2時,答案是錯誤的,因此它必須小於2。與副本數無關。

暫無
暫無

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

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