我可以根据 Elasticsearch 聚合中的查询更改结果分数吗?

dot*_*ear 5 elasticsearch nest kibana

我正在使用带有嵌套 top_hits 聚合的 Elasticsearch 过滤器聚合来检索基于不同过滤器的最匹配文档,但我似乎无法通过 boosting 或嵌套的 function_score 查询更改每个存储桶中的结果分数。这是不可能的吗?我没有找到任何明确的文档说它不起作用,并且查询执行得很好,但是结果分数不受影响。

示例查询(注意第一次聚合中的巨大提升):

GET _search
{  
   "size":0,
   "query":{  
      "bool":{  
         "should":[  
            {  
               "multi_match":{  
                  "type":"phrase",
                  "query":"TV",
                  "fields":[  
                     "categories^4"
                  ]
               }
            }
         ]
      }
   },
   "aggs":{  
      "1":{  
         "filter":{  
            "bool":{  
               "must":[  
                  {  
                     "multi_match":{  
                        "type":"phrase",
                        "query":"Music",
                        "fields":[  
                           "categories^10"
                        ]
                     }
                  }
               ]
            }
         },
         "aggs":{  
            "1_hits":{  
               "top_hits":{  
                  "size":10,
                  "sort":[  
                     {  
                        "_score":{  
                           "order":"desc"
                        }
                     }
                  ]
               }
            }
         }
      },
      "2":{  
         "filter":{  
            "bool":{  
               "must":[  
                  {  
                     "multi_match":{  
                        "type":"phrase",
                        "query":"Music",
                        "fields":[  
                           "categories"
                        ]
                     }
                  }
               ]
            }
         },
         "aggs":{  
            "2_hits":{  
               "top_hits":{  
                  "size":10,
                  "sort":[  
                     {  
                        "_score":{  
                           "order":"desc"
                        }
                     }
                  ]
               }
            }
         }
      }
   }
}
Run Code Online (Sandbox Code Playgroud)