-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Default semantic_text fields to ELSER on EIS when available #134708
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
Open
mridula-s109
wants to merge
36
commits into
elastic:main
Choose a base branch
from
mridula-s109:default_elser_on_eis_semantic
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
328d079
Defaulting EIS on ELSER
mridula-s109 0b89373
Extended testing
mridula-s109 1cc9fd4
[CI] Auto commit changes from spotless
0829058
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 7dcd31f
Edited to include the default
mridula-s109 f19972e
Cleaned up the mapper implementation
mridula-s109 3d58a50
COmpile issue
mridula-s109 394bf99
[CI] Auto commit changes from spotless
213aa24
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 c92d2b3
Added tests
mridula-s109 1301a43
[CI] Auto commit changes from spotless
6ecdb6c
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 9f662ce
Refactored the variable names
mridula-s109 904a242
Cleanup done
mridula-s109 6355bed
Removed unnecessary files
mridula-s109 b4ed763
Unit tests and mock is working
mridula-s109 4f0d7c0
[CI] Auto commit changes from spotless
4680417
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 18f38b8
Fix test
mridula-s109 cc2e978
yaml addition failure
mridula-s109 33f4eaa
[CI] Auto commit changes from spotless
6ef7543
Resolved the import issue or duplication of variables in mock
mridula-s109 7733cfe
Resolved PR comments
mridula-s109 70a80a4
Restored error
mridula-s109 9564444
Update docs/changelog/134708.yaml
mridula-s109 0a678ed
Integration test
mridula-s109 d23256b
[CI] Auto commit changes from spotless
f0fc256
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 0edfb91
Resolved all PR comments
mridula-s109 f3c0da5
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 dd765ae
[CI] Auto commit changes from spotless
5d932ef
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 536d326
Cleaned up the redudant reference of TestInferencePlugin
mridula-s109 cd98727
Included both before and before test
mridula-s109 cf797e4
[CI] Auto commit changes from spotless
9e50bdc
Merge branch 'main' into default_elser_on_eis_semantic
mridula-s109 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: 134708 | ||
summary: Default `semantic_text` fields to ELSER on EIS when available | ||
area: Mapping | ||
type: enhancement | ||
issues: [] |
71 changes: 71 additions & 0 deletions
71
...sts/src/javaRestTest/java/org/elasticsearch/xpack/inference/SemanticTextEISDefaultIT.java
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,71 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. | ||
* Licensed under the Elastic License 2.0; you may not use this file except | ||
* in compliance with the Elastic License 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.inference; | ||
|
||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.xcontent.support.XContentMapValues; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
|
||
import java.io.IOException; | ||
import java.util.Map; | ||
|
||
import static org.elasticsearch.xpack.inference.mapper.SemanticTextFieldMapper.DEFAULT_EIS_ELSER_INFERENCE_ID; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
/** | ||
* End-to-end test that verifies semantic_text fields automatically default to ELSER on EIS | ||
* when available and no inference_id is explicitly provided. | ||
*/ | ||
public class SemanticTextEISDefaultIT extends BaseMockEISAuthServerTest { | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
// Ensure the mock EIS server has an authorized response ready before each test | ||
mockEISServer.enqueueAuthorizeAllModelsResponse(); | ||
} | ||
|
||
/** | ||
* This is done before the class because I've run into issues where another class that extends {@link BaseMockEISAuthServerTest} | ||
* results in an authorization response not being queued up for the new Elasticsearch Node in time. When the node starts up, it | ||
* retrieves authorization. If the request isn't queued up when that happens the tests will fail. From my testing locally it seems | ||
* like the base class's static functionality to queue a response is only done once and not for each subclass. | ||
* | ||
* My understanding is that the @Before will be run after the node starts up and wouldn't be sufficient to handle | ||
* this scenario. That is why this needs to be @BeforeClass. | ||
*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was initially unsure about keeping this comment due to potential redundancy, but decided to leave it as-is since the added verbosity makes it more explanatory. |
||
@BeforeClass | ||
public static void init() { | ||
// Ensure the mock EIS server has an authorized response ready | ||
mockEISServer.enqueueAuthorizeAllModelsResponse(); | ||
} | ||
|
||
public void testDefaultInferenceIdForSemanticText() throws IOException { | ||
String indexName = "semantic-index"; | ||
String mapping = """ | ||
{ | ||
"properties": { | ||
"semantic_text_field": { | ||
"type": "semantic_text" | ||
} | ||
} | ||
} | ||
"""; | ||
Settings settings = Settings.builder().build(); | ||
createIndex(indexName, settings, mapping); | ||
|
||
Map<String, Object> mappingAsMap = getIndexMappingAsMap(indexName); | ||
String populatedInferenceId = (String) XContentMapValues.extractValue("properties.semantic_text_field.inference_id", mappingAsMap); | ||
|
||
assertThat( | ||
"semantic_text field should default to ELSER on EIS when available", | ||
populatedInferenceId, | ||
equalTo(DEFAULT_EIS_ELSER_INFERENCE_ID) | ||
); | ||
} | ||
|
||
} |
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
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.
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.
Based on my understanding of the conversation in #134708 (comment) (and the linked references), I think we only need the
@BeforeClass
annotated method. However, this additional@Before
method will be harmless at worst, so nothing to block over. As @ioanatia said earlier, we can sync with the ML team and clean this up later.