-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Add option to include or exclude vectors from _source retrieval #128735
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 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
74182d5
Add option to include or exclude vectors from _source retrieval
jimczi 09b23f4
Update docs/changelog/128735.yaml
jimczi 95d7014
Merge remote-tracking branch 'upstream/main' into include_vectors_sou…
jimczi cd54bab
Merge remote-tracking branch 'origin/include_vectors_source_option' i…
jimczi 26413b8
fix boolean logic
jimczi 9e9e8b3
handle semantic field pattern
jimczi fc037eb
address review comments
jimczi 137465a
Merge remote-tracking branch 'upstream/main' into include_vectors_sou…
jimczi eaede93
fix new transport version id
jimczi 1a06b2f
remove leftover
jimczi 4bd637a
Merge remote-tracking branch 'upstream/main' into include_vectors_sou…
jimczi 5258eac
typo
jimczi a2517b1
rename include_vectors into exclude_vectors
jimczi 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: 128735 | ||
| summary: Add option to include or exclude vectors from `_source` retrieval | ||
| area: Vector Search | ||
| type: feature | ||
| issues: [] |
225 changes: 225 additions & 0 deletions
225
...c/yamlRestTest/resources/rest-api-spec/test/search.vectors/230_include_vectors_search.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,225 @@ | ||
| setup: | ||
| - requires: | ||
| reason: 'include_vectors option is required' | ||
| test_runner_features: [ capabilities ] | ||
| capabilities: | ||
| - method: GET | ||
| path: /_search | ||
| capabilities: [ include_vectors_param ] | ||
| - skip: | ||
| features: "headers" | ||
|
|
||
| - do: | ||
| indices.create: | ||
| index: test | ||
| body: | ||
| mappings: | ||
| properties: | ||
| name: | ||
| type: keyword | ||
| sparse_vector: | ||
| type: sparse_vector | ||
| vector: | ||
| type: dense_vector | ||
| dims: 5 | ||
| similarity: l2_norm | ||
|
|
||
| nested: | ||
| type: nested | ||
| properties: | ||
| paragraph_id: | ||
| type: keyword | ||
| vector: | ||
| type: dense_vector | ||
| dims: 5 | ||
| similarity: l2_norm | ||
| sparse_vector: | ||
| type: sparse_vector | ||
|
|
||
| - do: | ||
| index: | ||
| index: test | ||
| id: "1" | ||
| body: | ||
| name: cow.jpg | ||
| vector: [36, 267, -311, 12, -202] | ||
|
|
||
| - do: | ||
| index: | ||
| index: test | ||
| id: "2" | ||
| body: | ||
| name: moose.jpg | ||
| nested: | ||
| - paragraph_id: 0 | ||
| vector: [-0.5, 100.0, -13, 14.8, -156.0] | ||
| - paragraph_id: 2 | ||
| vector: [0, 100.0, 0, 14.8, -156.0] | ||
| - paragraph_id: 3 | ||
| vector: [0, 1.0, 0, 1.8, -15.0] | ||
|
|
||
| - do: | ||
| index: | ||
| index: test | ||
| id: "3" | ||
| body: | ||
| name: rabbit.jpg | ||
| vector: [-0.5, 100.0, -13, 14.8, -156.0] | ||
| sparse_vector: | ||
| running: 3 | ||
| good: 17 | ||
| run: 22 | ||
|
|
||
| - do: | ||
| index: | ||
| index: test | ||
| id: "4" | ||
| body: | ||
| name: zoolander.jpg | ||
| nested: | ||
| - paragraph_id: 0 | ||
| vector: [ -0.5, 100.0, -13, 14.8, -156.0 ] | ||
| sparse_vector: | ||
| running: 3 | ||
| good: 17 | ||
| run: 22 | ||
| - paragraph_id: 1 | ||
| sparse_vector: | ||
| modeling: 32 | ||
| model: 20 | ||
| mode: 54 | ||
| - paragraph_id: 2 | ||
| vector: [ -9.8, 109, 32, 14.8, 23 ] | ||
|
|
||
|
|
||
| - do: | ||
| indices.refresh: {} | ||
|
|
||
| --- | ||
| "exclude vectors": | ||
| - do: | ||
| search: | ||
| index: test | ||
| body: | ||
| _source: | ||
| include_vectors: false | ||
| sort: ["name"] | ||
|
|
||
| - match: { hits.hits.0._id: "1"} | ||
| - match: { hits.hits.0._source.name: "cow.jpg"} | ||
| - not_exists: hits.hits.0._source.vector | ||
|
|
||
| - match: { hits.hits.1._id: "2"} | ||
| - match: { hits.hits.1._source.name: "moose.jpg"} | ||
| - length: { hits.hits.1._source.nested: 3 } | ||
| - not_exists: hits.hits.1._source.nested.0.vector | ||
| - match: { hits.hits.1._source.nested.0.paragraph_id: 0 } | ||
| - not_exists: hits.hits.1._source.nested.1.vector | ||
| - match: { hits.hits.1._source.nested.1.paragraph_id: 2 } | ||
| - not_exists: hits.hits.1._source.nested.2.vector | ||
| - match: { hits.hits.1._source.nested.2.paragraph_id: 3 } | ||
|
|
||
| - match: { hits.hits.2._id: "3" } | ||
| - match: { hits.hits.2._source.name: "rabbit.jpg" } | ||
| - not_exists: hits.hits.2._source.vector | ||
| - not_exists: hits.hits.2._source.sparse_vector | ||
|
|
||
| - match: { hits.hits.3._id: "4" } | ||
| - match: { hits.hits.3._source.name: "zoolander.jpg" } | ||
| - length: { hits.hits.3._source.nested: 3 } | ||
| - not_exists: hits.hits.3._source.nested.0.vector | ||
| - not_exists: hits.hits.3._source.nested.0.sparse_vector | ||
| - match: { hits.hits.3._source.nested.0.paragraph_id: 0 } | ||
| - not_exists: hits.hits.3._source.nested.1.sparse_vector | ||
| - match: { hits.hits.3._source.nested.1.paragraph_id: 1 } | ||
| - not_exists: hits.hits.3._source.nested.2.vector | ||
| - match: { hits.hits.3._source.nested.2.paragraph_id: 2 } | ||
|
|
||
| --- | ||
| "include vectors": | ||
| - do: | ||
| search: | ||
| index: test | ||
| body: | ||
| _source: | ||
| include_vectors: true | ||
jimczi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| sort: ["name"] | ||
|
|
||
| - match: { hits.hits.0._id: "1"} | ||
| - match: { hits.hits.0._source.name: "cow.jpg"} | ||
| - exists: hits.hits.0._source.vector | ||
|
|
||
| - match: { hits.hits.1._id: "2"} | ||
| - match: { hits.hits.1._source.name: "moose.jpg"} | ||
| - length: { hits.hits.1._source.nested: 3 } | ||
| - exists: hits.hits.1._source.nested.0.vector | ||
| - match: { hits.hits.1._source.nested.0.paragraph_id: 0 } | ||
| - exists: hits.hits.1._source.nested.1.vector | ||
| - match: { hits.hits.1._source.nested.1.paragraph_id: 2 } | ||
| - exists: hits.hits.1._source.nested.2.vector | ||
| - match: { hits.hits.1._source.nested.2.paragraph_id: 3 } | ||
|
|
||
| - match: { hits.hits.2._id: "3" } | ||
| - match: { hits.hits.2._source.name: "rabbit.jpg" } | ||
| - exists: hits.hits.2._source.vector | ||
| - exists: hits.hits.2._source.sparse_vector | ||
|
|
||
| - match: { hits.hits.3._id: "4" } | ||
| - match: { hits.hits.3._source.name: "zoolander.jpg" } | ||
| - length: { hits.hits.3._source.nested: 3 } | ||
| - exists: hits.hits.3._source.nested.0.vector | ||
| - exists: hits.hits.3._source.nested.0.sparse_vector | ||
| - match: { hits.hits.3._source.nested.0.paragraph_id: 0 } | ||
| - exists: hits.hits.3._source.nested.1.sparse_vector | ||
| - match: { hits.hits.3._source.nested.1.paragraph_id: 1 } | ||
| - exists: hits.hits.3._source.nested.2.vector | ||
| - match: { hits.hits.3._source.nested.2.paragraph_id: 2 } | ||
|
|
||
| --- | ||
| "exclude vectors with fields": | ||
| - do: | ||
| search: | ||
| index: test | ||
| body: | ||
| _source: | ||
| include_vectors: false | ||
| sort: ["name"] | ||
| fields: [vector, sparse_vector, nested.*] | ||
|
|
||
| - match: { hits.hits.0._id: "1"} | ||
| - match: { hits.hits.0._source.name: "cow.jpg"} | ||
| - not_exists: hits.hits.0._source.vector | ||
| - exists: hits.hits.0.fields.vector | ||
|
|
||
| - match: { hits.hits.1._id: "2"} | ||
| - match: { hits.hits.1._source.name: "moose.jpg"} | ||
| - length: { hits.hits.1._source.nested: 3 } | ||
| - not_exists: hits.hits.1._source.nested.0.vector | ||
| - match: { hits.hits.1._source.nested.0.paragraph_id: 0 } | ||
| - not_exists: hits.hits.1._source.nested.1.vector | ||
| - match: { hits.hits.1._source.nested.1.paragraph_id: 2 } | ||
| - not_exists: hits.hits.1._source.nested.2.vector | ||
| - match: { hits.hits.1._source.nested.2.paragraph_id: 3 } | ||
|
|
||
| - match: { hits.hits.2._id: "3" } | ||
| - match: { hits.hits.2._source.name: "rabbit.jpg" } | ||
| - not_exists: hits.hits.2._source.vector | ||
| - exists: hits.hits.2.fields.vector | ||
| - not_exists: hits.hits.2._source.sparse_vector | ||
| - exists: hits.hits.2.fields.sparse_vector | ||
|
|
||
|
|
||
| - match: { hits.hits.3._id: "4" } | ||
| - match: { hits.hits.3._source.name: "zoolander.jpg" } | ||
| - length: { hits.hits.3._source.nested: 3 } | ||
| - not_exists: hits.hits.3._source.nested.0.vector | ||
| - exists: hits.hits.3.fields.nested.0.vector | ||
| - not_exists: hits.hits.3._source.nested.0.sparse_vector | ||
| - match: { hits.hits.3._source.nested.0.paragraph_id: 0 } | ||
| - exists: hits.hits.3.fields.nested.0.sparse_vector | ||
| - not_exists: hits.hits.3._source.nested.1.sparse_vector | ||
| - match: { hits.hits.3._source.nested.1.paragraph_id: 1 } | ||
| - exists: hits.hits.3.fields.nested.1.sparse_vector | ||
| - not_exists: hits.hits.3._source.nested.2.vector | ||
| - match: { hits.hits.3._source.nested.2.paragraph_id: 2 } | ||
| - exists: hits.hits.3.fields.nested.2.vector | ||
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
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
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.