Allow updating inference_id of semantic_text fields#136120
Conversation
Previously the `inference_id` of `semantic_text` fields was not updatable. This commit allows users to update the `inference_id` of a `semantic_text` field. This is particularly useful for scenarios where the user wants to switch to using the same model but from a different service. There are two circumstances when the update is allowed. - No values have been written for the `semantic_text` field. The inference endpoint can be changed freely as there is no need for compatibility between the current and the new endpoint. - The new inference endpoint is compatible with the previous one. The `model_settings` of the new inference endpoint are compatible with those of the current endpoint, thus the update is allowed.
|
Pinging @elastic/search-relevance (Team:Search - Relevance) |
|
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
|
Hi @dimitris-athanasiou, I've created a changelog YAML for you. |
|
PR is ready for review. However, I intend to add documentation changes soon. |
🔍 Preview links for changed docs |
ℹ️ Important: Docs version tagging👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version. We use applies_to tags to mark version-specific features and changes. Expand for a quick overviewWhen to use applies_to tags:✅ At the page level to indicate which products/deployments the content applies to (mandatory) What NOT to do:❌ Don't remove or replace information that applies to an older version 🤔 Need help?
|
leemthompo
left a comment
There was a problem hiding this comment.
Couple of very minor wording suggestions from me :)
docs/reference/elasticsearch/mapping-reference/semantic-text.md
Outdated
Show resolved
Hide resolved
docs/reference/elasticsearch/mapping-reference/semantic-text.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Liam Thompson <leemthompo@gmail.com>
Co-authored-by: Liam Thompson <leemthompo@gmail.com>
kderusso
left a comment
There was a problem hiding this comment.
Nice work! I've left a few comments but I think it's pretty close.
docs/reference/elasticsearch/mapping-reference/semantic-text.md
Outdated
Show resolved
Hide resolved
...rc/main/java/org/elasticsearch/xpack/inference/mock/TestSparseInferenceServiceExtension.java
Outdated
Show resolved
Hide resolved
...nference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Show resolved
Hide resolved
| * @param modelSettings the new model settings. If null the mapper will be returned unchanged. | ||
| * @return A mapper with the copied settings applied | ||
| */ | ||
| private SemanticTextFieldMapper copyWithNewModelSettingsIfNotSet( |
There was a problem hiding this comment.
So we're doing a null check here before we copy the settings, but we silently ignore if that case happens. Should we throw if it's not null and this method is called?
There was a problem hiding this comment.
It could be that it's not null because the update itself contains model_settings. In that case the explicitly set model_settings take precedence.
There was a problem hiding this comment.
Didn't review this file, assume it's the same as the other yaml test
...e/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml
Show resolved
Hide resolved
Co-authored-by: Kathleen DeRusso <kathleen.derusso@elastic.co>
Mikep86
left a comment
There was a problem hiding this comment.
Partial review, didn't get to the tests. I'll pick it up next week.
...nference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Outdated
Show resolved
Hide resolved
...nference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Outdated
Show resolved
Hide resolved
...nference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Outdated
Show resolved
Hide resolved
...nference/src/main/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapper.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Mike Pellegrini <mike.pellegrini@elastic.co>
Mikep86
left a comment
There was a problem hiding this comment.
Production code looks good! I left some comments about test adjustments, other than that we're good to go 🚀
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Show resolved
Hide resolved
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Show resolved
Hide resolved
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Show resolved
Hide resolved
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Outdated
Show resolved
Hide resolved
...e/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml
Show resolved
Hide resolved
...c/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping_bwc.yml
Show resolved
Hide resolved
...e/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml
Show resolved
Hide resolved
...e/src/yamlRestTest/resources/rest-api-spec/test/inference/10_semantic_text_field_mapping.yml
Show resolved
Hide resolved
docs/reference/elasticsearch/mapping-reference/semantic-text.md
Outdated
Show resolved
Hide resolved
|
@Mikep86 Thank you for the review! I have addressed all your feedback. I replied on replacing those tests with randomized testing that I'd prefer to keep it that way explaining my reasons. Let me know what you think. Otherwise, should be good to go now! |
Mikep86
left a comment
There was a problem hiding this comment.
LGTM, I left one comment about how we could improve the assertions on the embeddings mappers
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Show resolved
Hide resolved
...nce/src/test/java/org/elasticsearch/xpack/inference/mapper/SemanticTextFieldMapperTests.java
Show resolved
Hide resolved
Previously the `inference_id` of `semantic_text` fields was not updatable. This commit allows users to update the `inference_id` of a `semantic_text` field. This is particularly useful for scenarios where the user wants to switch to using the same model but from a different service. There are two circumstances when the update is allowed. - No values have been written for the `semantic_text` field. The inference endpoint can be changed freely as there is no need for compatibility between the current and the new endpoint. - The new inference endpoint is compatible with the previous one. The `model_settings` of the new inference endpoint are compatible with those of the current endpoint, thus the update is allowed.
Previously the `inference_id` of `semantic_text` fields was not updatable. This commit allows users to update the `inference_id` of a `semantic_text` field. This is particularly useful for scenarios where the user wants to switch to using the same model but from a different service. There are two circumstances when the update is allowed. - No values have been written for the `semantic_text` field. The inference endpoint can be changed freely as there is no need for compatibility between the current and the new endpoint. - The new inference endpoint is compatible with the previous one. The `model_settings` of the new inference endpoint are compatible with those of the current endpoint, thus the update is allowed.
Previously the
inference_idofsemantic_textfields was not updatable. This commit allows users to update theinference_idof asemantic_textfield. This is particularly useful for scenarios where the user wants to switch to using the same model but from a different service.There are two circumstances when the update is allowed.
semantic_textfield.The inference endpoint can be changed freely as there is no need for compatibility between the current and the new endpoint.
The
model_settingsof the new inference endpoint are compatible with those of the current endpoint, thus the update is allowed.