forked from elastic/elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for more than one inner_hit when searching nested vectors (…
…elastic#104006) This commit adds the ability to gather more than one inner_hit when searching nested kNN. # Global kNN example ``` POST test/_search { "_source": false, "fields": [ "name" ], "knn": { "field": "nested.vector", "query_vector": [ -0.5, 90, -10, 14.8, -156 ], "k": 3, "num_candidates": 3, "inner_hits": { "size": 2, "fields": [ "nested.paragraph_id" ], "_source": false } } } ``` Results in <details> ``` { "took": 66, "timed_out": false, "_shards": { "total": 2, "successful": 2, "skipped": 0, "failed": 0 }, "hits": { "total": { "value": 2, "relation": "eq" }, "max_score": 0.009090909, "hits": [ { "_index": "test", "_id": "2", "_score": 0.009090909, "fields": { "name": [ "moose.jpg" ] }, "inner_hits": { "nested": { "hits": { "total": { "value": 2, "relation": "eq" }, "max_score": 0.009090909, "hits": [ { "_index": "test", "_id": "2", "_nested": { "field": "nested", "offset": 0 }, "_score": 0.009090909, "fields": { "nested": [ { "paragraph_id": [ "0" ] } ] } }, { "_index": "test", "_id": "2", "_nested": { "field": "nested", "offset": 1 }, "_score": 0.004968944, "fields": { "nested": [ { "paragraph_id": [ "2" ] } ] } } ] } } } }, { "_index": "test", "_id": "3", "_score": 0.0021519717, "fields": { "name": [ "rabbit.jpg" ] }, "inner_hits": { "nested": { "hits": { "total": { "value": 1, "relation": "eq" }, "max_score": 0.0021519717, "hits": [ { "_index": "test", "_id": "3", "_nested": { "field": "nested", "offset": 0 }, "_score": 0.0021519717, "fields": { "nested": [ { "paragraph_id": [ "0" ] } ] } } ] } } } } ] } } ``` </details> # kNN Query example With a kNN query, this opens an interesting door, which allows for multiple inner_hit scoring schemes. ## Nearest by max passage only ``` POST test/_search { "size": 3, "query": { "nested": { "path": "nested", "score_mode": "max", "query": { "knn": { "field": "nested.vector", "query_vector": [ -0.5, 90, -10, 14.8, -156 ], "num_candidates": 5 } }, "inner_hits": { "size": 2, "_source": false, "fields": [ "nested.paragraph_id" ] } } } } ``` </details> closes: elastic#102950
- Loading branch information
Showing
24 changed files
with
908 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 104006 | ||
summary: Add support for more than one `inner_hit` when searching nested vectors | ||
area: Vector Search | ||
type: enhancement | ||
issues: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.