-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Wrap ES KNN queries with PatienceKNN query #127223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 65 commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
e893304
wrap ES knn queries with patience query
tteofili a0634d4
[CI] Auto commit changes from spotless
elasticsearchmachine 2bf80db
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 88a80a0
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili 7918023
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 28740aa
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili e62dac9
[CI] Auto commit changes from spotless
elasticsearchmachine 6ac3440
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 681ffca
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili 23494d1
refactoring, test fixes
tteofili ef92d63
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili acd122f
[CI] Auto commit changes from spotless
elasticsearchmachine a077ce1
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 4b2029c
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili 98c42d2
make early termination disabled by default
tteofili cbae622
add patience and saturation threshold params
tteofili a186b9d
spotless
tteofili 8be88b3
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 56b8ff8
[CI] Auto commit changes from spotless
elasticsearchmachine 54afb00
minor fix
tteofili 94ec3ec
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili e5caaa9
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 571e68f
[CI] Auto commit changes from spotless
elasticsearchmachine e40d171
minor fix
tteofili 0dcb0b2
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili bf4e660
refactored and simplified, added option to knn tester
tteofili 4419b2a
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili c7bcb82
reverted docs changes
tteofili f5fbbb4
[CI] Auto commit changes from spotless
elasticsearchmachine ee047a8
adjusted knnsearcher
tteofili 0f7d6d3
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 19df568
default index settings test
tteofili dbdbc6d
test fixes
tteofili 4df4be2
[CI] Auto commit changes from spotless
elasticsearchmachine 32a68aa
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 69f9228
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili b5c52da
Merge
tteofili ac4c879
[CI] Auto commit changes from spotless
elasticsearchmachine c52837a
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 15f1ae9
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili fe4c080
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 8967a5c
test fix
tteofili ab55674
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili fa06fbd
test fix
tteofili 6b70605
test fix
tteofili 483960f
rest compatibility check with search features
tteofili 99c3994
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 4446bfa
rest compatibility check with search features
tteofili e8fcd52
rest compatibility check with search features
tteofili 89b5273
rest compatibility check with search features
tteofili 631b738
index version check
tteofili d647aae
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 4033256
fixed testMeta
tteofili 783f811
test fix
tteofili c89b98c
use indexVersion in minimalMapping
tteofili 4b56411
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili f03029d
spotless
tteofili d9bd374
test fix
tteofili 0d39004
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 95b061c
skip rest compat test
tteofili 0efd8d9
skip rest compat test
tteofili 5b5c997
add yaml test
tteofili 197bb58
yaml test fix
tteofili 4bdec28
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili 840d3fd
Update docs/changelog/127223.yaml
tteofili e1dfb2c
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili dae3d72
switch to dynamic index setting
tteofili 8de4fda
Update server/src/main/java/org/elasticsearch/index/mapper/vectors/De…
tteofili c5a51e9
simplify and typo fix
tteofili 1a6ca1a
Merge branch 'knn_patience' of github.com:tteofili/elasticsearch into…
tteofili 0402eef
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili c2ef4d2
remove unneeded changes
tteofili 571c2ca
simplify
tteofili 768a513
revert unneeded change
tteofili 629741a
Merge branch 'main' of github.com:elastic/elasticsearch into knn_pati…
tteofili File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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: 127223 | ||
summary: Wrap ES KNN queries with PatienceKNN query | ||
area: Vector Search | ||
type: feature | ||
issues: [] |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
168 changes: 168 additions & 0 deletions
168
...RestTest/resources/rest-api-spec/test/search.vectors/240_knn_search_early_termination.yml
This file contains hidden or 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,168 @@ | ||
setup: | ||
- requires: | ||
cluster_features: [ "search.vectors.mappers.expose_hnsw_early_termination" ] | ||
reason: "requires early termination for hnsw to be exposed" | ||
- do: | ||
indices.create: | ||
index: bbq_hnsw | ||
body: | ||
settings: | ||
index: | ||
number_of_shards: 1 | ||
mappings: | ||
properties: | ||
vector: | ||
type: dense_vector | ||
dims: 64 | ||
index: true | ||
similarity: max_inner_product | ||
index_options: | ||
type: bbq_hnsw | ||
early_termination: true | ||
|
||
- do: | ||
index: | ||
index: bbq_hnsw | ||
id: "1" | ||
body: | ||
vector: [0.077, 0.32 , -0.205, 0.63 , 0.032, 0.201, 0.167, -0.313, | ||
0.176, 0.531, -0.375, 0.334, -0.046, 0.078, -0.349, 0.272, | ||
0.307, -0.083, 0.504, 0.255, -0.404, 0.289, -0.226, -0.132, | ||
-0.216, 0.49 , 0.039, 0.507, -0.307, 0.107, 0.09 , -0.265, | ||
-0.285, 0.336, -0.272, 0.369, -0.282, 0.086, -0.132, 0.475, | ||
-0.224, 0.203, 0.439, 0.064, 0.246, -0.396, 0.297, 0.242, | ||
-0.028, 0.321, -0.022, -0.009, -0.001 , 0.031, -0.533, 0.45, | ||
-0.683, 1.331, 0.194, -0.157, -0.1 , -0.279, -0.098, -0.176] | ||
- do: | ||
index: | ||
index: bbq_hnsw | ||
id: "2" | ||
body: | ||
vector: [0.196, 0.514, 0.039, 0.555, -0.042, 0.242, 0.463, -0.348, | ||
-0.08 , 0.442, -0.067, -0.05 , -0.001, 0.298, -0.377, 0.048, | ||
0.307, 0.159, 0.278, 0.119, -0.057, 0.333, -0.289, -0.438, | ||
-0.014, 0.361, -0.169, 0.292, -0.229, 0.123, 0.031, -0.138, | ||
-0.139, 0.315, -0.216, 0.322, -0.445, -0.059, 0.071, 0.429, | ||
-0.602, -0.142, 0.11 , 0.192, 0.259, -0.241, 0.181, -0.166, | ||
0.082, 0.107, -0.05 , 0.155, 0.011, 0.161, -0.486, 0.569, | ||
-0.489, 0.901, 0.208, 0.011, -0.209, -0.153, -0.27 , -0.013] | ||
|
||
- do: | ||
index: | ||
index: bbq_hnsw | ||
id: "3" | ||
body: | ||
name: rabbit.jpg | ||
vector: [0.139, 0.178, -0.117, 0.399, 0.014, -0.139, 0.347, -0.33 , | ||
0.139, 0.34 , -0.052, -0.052, -0.249, 0.327, -0.288, 0.049, | ||
0.464, 0.338, 0.516, 0.247, -0.104, 0.259, -0.209, -0.246, | ||
-0.11 , 0.323, 0.091, 0.442, -0.254, 0.195, -0.109, -0.058, | ||
-0.279, 0.402, -0.107, 0.308, -0.273, 0.019, 0.082, 0.399, | ||
-0.658, -0.03 , 0.276, 0.041, 0.187, -0.331, 0.165, 0.017, | ||
0.171, -0.203, -0.198, 0.115, -0.007, 0.337, -0.444, 0.615, | ||
-0.657, 1.285, 0.2 , -0.062, 0.038, 0.089, -0.068, -0.058] | ||
- do: | ||
index: | ||
index: bbq_hnsw | ||
id: "4" | ||
body: | ||
vector: [ 0.123, 0.32 , -0.205, -0.63 , 0.132, 0.201, 0.167, -0.313, | ||
0.176, 0.531, -0.375, 0.334, -0.046, 0.078, -0.349, 0.272, | ||
0.307, -0.083, 0.504, 0.255, -0.904, 0.289, -0.226, -0.132, | ||
-0.216, 0.49 , 0.039, 0.507, -0.307, 0.107, 0.09 , -0.265, | ||
-0.285, 0.336, -0.272, 0.161, -0.282, 0.086, -0.132, 0.475, | ||
-0.224, 0.203, 0.439, 0.064, 0.246, -0.396, 0.297, 0.242, | ||
-0.028, 0.321, -0.032, -0.009, -0.001 , 0.031, -0.533, 0.45, | ||
-0.683, 1.331, 0.294, -0.157, -0.1 , -0.279, -0.098, -0.176 ] | ||
|
||
- do: | ||
index: | ||
index: bbq_hnsw | ||
id: "5" | ||
body: | ||
vector: [ 0.456, 0.32 , -0.205, 0.63 , 0.032, 0.201, 0.167, -0.313, | ||
0.176, 0.531, -0.375, 0.334, -0.103, 0.078, -0.488, 0.272, | ||
0.307, -0.083, 0.504, 0.255, -0.404, 0.289, -0.226, -0.132, | ||
-0.216, 0.49 , 0.039, 0.507, -0.307, 0.107, 0.084 , -0.093, | ||
-0.285, 0.336, -0.272, 0.369, -0.743, 0.086, -0.132, 0.475, | ||
-0.224, 0.203, -0.439, 0.064, 0.246, -0.396, 0.297, 0.242, | ||
-0.028, 0.321, -0.022, -0.009, -0.001 , 0.031, -0.533, 0.45, | ||
-0.683, 1.331, 0.194, -0.157, -0.1 , -0.279, -0.098, -0.789 ] | ||
- do: | ||
indices.flush: | ||
index: bbq_hnsw | ||
|
||
- do: | ||
indices.refresh: {} | ||
|
||
--- | ||
"Run knn search with early termination": | ||
|
||
- do: | ||
search: | ||
index: bbq_hnsw | ||
body: | ||
query: | ||
knn: | ||
field: vector | ||
query_vector: [0.128, 0.067, -0.08 , 0.395, -0.11 , -0.259, 0.473, -0.393, | ||
0.292, 0.571, -0.491, 0.444, -0.288, 0.198, -0.343, 0.015, | ||
0.232, 0.088, 0.228, 0.151, -0.136, 0.236, -0.273, -0.259, | ||
-0.217, 0.359, -0.207, 0.352, -0.142, 0.192, -0.061, -0.17 , | ||
-0.343, 0.189, -0.221, 0.32 , -0.301, -0.1 , 0.005, 0.232, | ||
-0.344, 0.136, 0.252, 0.157, -0.13 , -0.244, 0.193, -0.034, | ||
-0.12 , -0.193, -0.102, 0.252, -0.185, -0.167, -0.575, 0.582, | ||
-0.426, 0.983, 0.212, 0.204, 0.03 , -0.276, -0.425, -0.158] | ||
num_candidates: 5 | ||
k: 3 | ||
|
||
- match: { hits.total.value: 3 } | ||
- match: { hits.hits.0._id: "5" } | ||
- match: { hits.hits.1._id: "1" } | ||
- match: { hits.hits.2._id: "3" } | ||
|
||
--- | ||
"Profile knn search with early termination": | ||
|
||
- do: | ||
search: | ||
index: bbq_hnsw | ||
body: | ||
profile: true | ||
query: | ||
knn: | ||
field: vector | ||
query_vector: [0.128, 0.067, -0.08 , 0.395, -0.11 , -0.259, 0.473, -0.393, | ||
0.292, 0.571, -0.491, 0.444, -0.288, 0.198, -0.343, 0.015, | ||
0.232, 0.088, 0.228, 0.151, -0.136, 0.236, -0.273, -0.259, | ||
-0.217, 0.359, -0.207, 0.352, -0.142, 0.192, -0.061, -0.17 , | ||
-0.343, 0.189, -0.221, 0.32 , -0.301, -0.1 , 0.005, 0.232, | ||
-0.344, 0.136, 0.252, 0.157, -0.13 , -0.244, 0.193, -0.034, | ||
-0.12 , -0.193, -0.102, 0.252, -0.185, -0.167, -0.575, 0.582, | ||
-0.426, 0.983, 0.212, 0.204, 0.03 , -0.276, -0.425, -0.158] | ||
k: 3 | ||
num_candidates: 3 | ||
|
||
- match: { profile.shards.0.dfs.knn.0.vector_operations_count: null } | ||
|
||
# Search with similarity to check number of operations are propagated correctly | ||
- do: | ||
search: | ||
index: bbq_hnsw | ||
body: | ||
profile: true | ||
knn: | ||
field: vector | ||
query_vector: [0.128, 0.067, -0.08 , 0.395, -0.11 , -0.259, 0.473, -0.393, | ||
0.292, 0.571, -0.491, 0.444, -0.288, 0.198, -0.343, 0.015, | ||
0.232, 0.088, 0.228, 0.151, -0.136, 0.236, -0.273, -0.259, | ||
-0.217, 0.359, -0.207, 0.352, -0.142, 0.192, -0.061, -0.17 , | ||
-0.343, 0.189, -0.221, 0.32 , -0.301, -0.1 , 0.005, 0.232, | ||
-0.344, 0.136, 0.252, 0.157, -0.13 , -0.244, 0.193, -0.034, | ||
-0.12 , -0.193, -0.102, 0.252, -0.185, -0.167, -0.575, 0.582, | ||
-0.426, 0.983, 0.212, 0.204, 0.03 , -0.276, -0.425, -0.158] | ||
k: 3 | ||
num_candidates: 3 | ||
similarity: 100000 | ||
|
||
- match: { profile.shards.0.dfs.knn.0.vector_operations_count: 5 } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.