5959import org .elasticsearch .xcontent .XContentBuilder ;
6060import org .elasticsearch .xcontent .XContentType ;
6161import org .elasticsearch .xcontent .json .JsonXContent ;
62- import org .elasticsearch .xpack .inference .DefaultElserFeatureFlag ;
6362import org .elasticsearch .xpack .inference .InferencePlugin ;
6463import org .elasticsearch .xpack .inference .model .TestModel ;
6564import org .junit .AssumptionViolatedException ;
@@ -97,9 +96,6 @@ protected Collection<? extends Plugin> getPlugins() {
9796 @ Override
9897 protected void minimalMapping (XContentBuilder b ) throws IOException {
9998 b .field ("type" , "semantic_text" );
100- if (DefaultElserFeatureFlag .isEnabled () == false ) {
101- b .field ("inference_id" , "test_model" );
102- }
10399 }
104100
105101 @ Override
@@ -169,9 +165,7 @@ public void testDefaults() throws Exception {
169165 DocumentMapper mapper = mapperService .documentMapper ();
170166 assertEquals (Strings .toString (fieldMapping ), mapper .mappingSource ().toString ());
171167 assertSemanticTextField (mapperService , fieldName , false );
172- if (DefaultElserFeatureFlag .isEnabled ()) {
173- assertInferenceEndpoints (mapperService , fieldName , DEFAULT_ELSER_2_INFERENCE_ID , DEFAULT_ELSER_2_INFERENCE_ID );
174- }
168+ assertInferenceEndpoints (mapperService , fieldName , DEFAULT_ELSER_2_INFERENCE_ID , DEFAULT_ELSER_2_INFERENCE_ID );
175169
176170 ParsedDocument doc1 = mapper .parse (source (this ::writeField ));
177171 List <IndexableField > fields = doc1 .rootDoc ().getFields ("field" );
@@ -205,15 +199,13 @@ public void testSetInferenceEndpoints() throws IOException {
205199 assertSerialization .accept (fieldMapping , mapperService );
206200 }
207201 {
208- if (DefaultElserFeatureFlag .isEnabled ()) {
209- final XContentBuilder fieldMapping = fieldMapping (
210- b -> b .field ("type" , "semantic_text" ).field (SEARCH_INFERENCE_ID_FIELD , searchInferenceId )
211- );
212- final MapperService mapperService = createMapperService (fieldMapping );
213- assertSemanticTextField (mapperService , fieldName , false );
214- assertInferenceEndpoints (mapperService , fieldName , DEFAULT_ELSER_2_INFERENCE_ID , searchInferenceId );
215- assertSerialization .accept (fieldMapping , mapperService );
216- }
202+ final XContentBuilder fieldMapping = fieldMapping (
203+ b -> b .field ("type" , "semantic_text" ).field (SEARCH_INFERENCE_ID_FIELD , searchInferenceId )
204+ );
205+ final MapperService mapperService = createMapperService (fieldMapping );
206+ assertSemanticTextField (mapperService , fieldName , false );
207+ assertInferenceEndpoints (mapperService , fieldName , DEFAULT_ELSER_2_INFERENCE_ID , searchInferenceId );
208+ assertSerialization .accept (fieldMapping , mapperService );
217209 }
218210 {
219211 final XContentBuilder fieldMapping = fieldMapping (
@@ -240,26 +232,18 @@ public void testInvalidInferenceEndpoints() {
240232 );
241233 }
242234 {
243- final String expectedMessage = DefaultElserFeatureFlag .isEnabled ()
244- ? "[inference_id] on mapper [field] of type [semantic_text] must not be empty"
245- : "[inference_id] on mapper [field] of type [semantic_text] must be specified" ;
246235 Exception e = expectThrows (
247236 MapperParsingException .class ,
248237 () -> createMapperService (fieldMapping (b -> b .field ("type" , "semantic_text" ).field (INFERENCE_ID_FIELD , "" )))
249238 );
250- assertThat (e .getMessage (), containsString (expectedMessage ));
239+ assertThat (e .getMessage (), containsString ("[inference_id] on mapper [field] of type [semantic_text] must not be empty" ));
251240 }
252241 {
253- if (DefaultElserFeatureFlag .isEnabled ()) {
254- Exception e = expectThrows (
255- MapperParsingException .class ,
256- () -> createMapperService (fieldMapping (b -> b .field ("type" , "semantic_text" ).field (SEARCH_INFERENCE_ID_FIELD , "" )))
257- );
258- assertThat (
259- e .getMessage (),
260- containsString ("[search_inference_id] on mapper [field] of type [semantic_text] must not be empty" )
261- );
262- }
242+ Exception e = expectThrows (
243+ MapperParsingException .class ,
244+ () -> createMapperService (fieldMapping (b -> b .field ("type" , "semantic_text" ).field (SEARCH_INFERENCE_ID_FIELD , "" )))
245+ );
246+ assertThat (e .getMessage (), containsString ("[search_inference_id] on mapper [field] of type [semantic_text] must not be empty" ));
263247 }
264248 }
265249
0 commit comments