簡體   English   中英

嵌套類型上的Elasticsearch post_filter不對聚合進行過濾

[英]Elasticsearch post_filter on nested types not filtering on aggregations

您好Elasticsearch專家,我需要您的幫助! 我們使用的是Elasticsearch v5.4,而我在Elasticsearch中有多種嵌套類型,其形式為:

"testLookup" : [
  {
    "id": 1001,
    "name": "test1"
  },
  {
    "id": 1002,
    "name": "test2"
  }
]

我正在嘗試將名稱顯示為過濾器中的復選框選項。

我試圖使用post_filter頂級元素來基本過濾聚合,因此我只能更新和顯示受影響的過濾器選項,有點像在此演示站點上的使用方式: http : //demo.searchkit.co

  "post_filter": {
    "bool":{
      "must": [
     {    
      "nested" : {
        "path" : "testLookup",
        "query": {
          "bool": {
            "filter":{ 
              "bool":{
                "should":[
                        { "term":  { "perTestLookup.name.keyword": "Adele"}}
         ]
            }
        }
      }
    }
    }
     },
              {    
    "nested" : {
      "path" : "testLookup2",
      "query": {
        "bool": {
          "filter":{ 
            "bool":{
              "should":[         
                { "term":  { "perTestLookup2.name.keyword": "Gene" }}
         ]
            }
        }
      }
    }
    }     
    }
  ]
 }
}

如果我沒記錯的話,我認為post_filter的作用是在發送搜索請求之前將過濾器應用於每個聚合,您可以通過在單擊其中一個過濾器后查看搜索過濾器的請求有效負載來觀察到這一點復選框。

但是,我無法獲取post_filter將篩選器應用於聚合,只是未應用篩選器。 為什么會這樣呢? 不支持嵌套類型的post_filter嗎?

任何提示或指導將不勝感激。 謝謝!

注意:我沒有任何Searchkit經驗。

在計算聚合以進一步減少命中結果之后,將執行Elasticsearch請求中的post_filter 請參閱有關post_filter的文檔。

其背后的想法是,在多面搜索(即按類別過濾)中,您仍然希望檢索聚合中所有類別的類別計數,但是您想為文檔中的單擊類別進行過濾搜索。

因此,這是從Elasticsearch角度來看的預期行為。

暫無
暫無

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

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