# Aggregate Score for Hybrid Search

**URL:** <https://discuss.elastic.co/t/aggregate-score-for-hybrid-search/325205>\
**Category:** Elasticsearch\
**Tags:** vector-search\
**Created:** [February 10, 2023, 12:02am UTC](https://discuss.elastic.co/t/aggregate-score-for-hybrid-search/325205 "2023-02-10T00:02:53Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![BenTrent](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bentrent/32/33915_2.png) [@BenTrent](https://discuss.elastic.co/u/BenTrent)\
**Post date:** [February 16, 2023, 6:35pm UTC](https://discuss.elastic.co/t/aggregate-score-for-hybrid-search/325205/22 "2023-02-16T18:35:56Z")

</div>

OK, got a bug fix ready!

> <https://github.com/elastic/elasticsearch/pull/93871>
>
> This PR addresses bugs with KNN search.
> 
> First, when searching with KNN, using… \`explain: true\` would give strange results. 
> 
> Even though a document obviously matches because of its score, the explanation would indicate that it did NOT match. This bug was because our explanation check was not accounting for the leaf-segment's docBase.
> 
> Second, when there are multiple segments, and KNN is used in hybrid search, some documents may go unscored by KNN.
> 
> The main issue here is the disjunction logic within \`BoolQuery\`. All hybrid queries with \`knn\` are pure disjunction queries under the hood. And Lucene does its best to optimize the documents it gathers in these types of queries.
> 
> Consequently, it will look for the maximum possible score for an entire segment leaf. However, the underlying KNN query would ALWAYS increment this passed docId by the segment's docBase (this is fairly ironic given the \`explain\` bug :D). This would cause the \`docId\` for calculating the maximum score to roll over to the negatives and thus knn would indicate its maximum score to be \`0\` for certain segments with higher docBase values.
> 
> closes: https://github.com/elastic/elasticsearch/issues/93830

Thanks again!

---

<div class="post-metadata">

**Author:** ![Kok\_Gin\_Xian](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kok_gin_xian/32/117084_2.png) [@Kok\_Gin\_Xian](https://discuss.elastic.co/u/Kok_Gin_Xian)\
**Post date:** [February 17, 2023, 1:12am UTC](https://discuss.elastic.co/t/aggregate-score-for-hybrid-search/325205/23 "2023-02-17T01:12:37Z")

</div>

Wow, that is quick. When will the bug fix incorporated into a new release? Meanwhile I can work with the workaround first.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 17, 2023, 1:13am UTC](https://discuss.elastic.co/t/aggregate-score-for-hybrid-search/325205/24 "2023-03-17T01:13:14Z")

</div>

Closed on March 17, 2023, 1:13am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.

[Previous page](https://discuss.elastic.co/t/aggregate-score-for-hybrid-search/325205.md?page=1)
