-
Notifications
You must be signed in to change notification settings - Fork 25.8k
Improve mutability handling of Source#source()'s map #141534
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't sure if I wanted to create a new class/spin up a new cluster for this one simple test. If there's a better home for the test, let me know.
server/src/main/java/org/elasticsearch/index/get/ShardGetService.java
Outdated
Show resolved
Hide resolved
|
Hi @tballison, I've created a changelog YAML for you. |
Mikep86
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice start! A few things to close this out:
- Can you add a similar YAML test to
30_semantic_text_inference_bwc.yml? This is the file for testing against the oldsemantic_textformat. In this case, setting_source_includes=_inference_fieldsshould have no effect. We should check it doesn't cause an error though, because that was a bug we fixed previously (see this test) - We should investigate ways to test the changes to
SearchBasedChangesSnapshot. - Can you update the PR title and changelog to be more specific? This bug fixes retrieving
_inference_fieldsvia_source_includes. There are other ways of getting_inference_fieldsthat work fine.
server/src/main/java/org/elasticsearch/index/get/ShardGetService.java
Outdated
Show resolved
Hide resolved
| var newSource = new HashMap<>(originalSource.source()); | ||
| newSource.put(InferenceMetadataFieldsMapper.NAME, values.get(0)); | ||
| return Source.fromMap(newSource, originalSource.sourceContentType()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch here! I wonder how we test this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I investigated how to test this and the short version is this path is already tested by SemanticInferenceMetadataFieldsRecoveryTests. I think we got lucky that the test works because originalSource just happens to store source in a mutable map. But we can't count on that always being the case, so we should keep this change.
@jimczi WDYT?
...rence/src/yamlRestTest/resources/rest-api-spec/test/inference/30_semantic_text_inference.yml
Outdated
Show resolved
Hide resolved
...rence/src/yamlRestTest/resources/rest-api-spec/test/inference/30_semantic_text_inference.yml
Outdated
Show resolved
Hide resolved
...rence/src/yamlRestTest/resources/rest-api-spec/test/inference/30_semantic_text_inference.yml
Outdated
Show resolved
Hide resolved
|
@elasticmachine update branch |
…s from semantic_text field
…archBasedChangesSnapshot
…ec/test/inference/30_semantic_text_inference.yml Co-authored-by: Mike Pellegrini <[email protected]>
91a3268 to
6195720
Compare
# Conflicts: # server/src/main/java/org/elasticsearch/index/IndexFeatures.java
|
Pinging @elastic/es-search-relevance (Team:Search Relevance) |
server/src/main/java/org/elasticsearch/search/lookup/Source.java
Outdated
Show resolved
Hide resolved
…to avoid unnecessary copying
Co-authored-by: Mike Pellegrini <[email protected]>
Co-authored-by: Mike Pellegrini <[email protected]>
Wrap source for mutability to allow updating with _inference_fields.
Fixes #141075
Is related to: #136545