@@ -722,18 +722,26 @@ public void testSparseVectorMappingUpdate() throws IOException {
722722 String fieldName = "field" ;
723723
724724 MapperService mapperService = createMapperService (
725- mapping (b -> addSemanticTextMapping (b , fieldName , model .getInferenceEntityId (), null , chunkingSettings , indexOptions )),
725+ mapping (b -> addSemanticTextMapping (
726+ b ,
727+ fieldName ,
728+ model .getInferenceEntityId (),
729+ null ,
730+ chunkingSettings ,
731+ indexOptions ,
732+ new MinimalServiceSettings (model )
733+ )),
726734 useLegacyFormat
727735 );
728- assertSemanticTextField (mapperService , fieldName , false , chunkingSettings , indexOptions );
736+ assertSemanticTextField (mapperService , fieldName , true , chunkingSettings , indexOptions );
729737
730738 final SemanticTextIndexOptions newIndexOptions = randomSemanticTextIndexOptions (TaskType .SPARSE_EMBEDDING );
731739 ChunkingSettings newChunkingSettings = generateRandomChunkingSettingsOtherThan (chunkingSettings );
732740 merge (
733741 mapperService ,
734742 mapping (b -> addSemanticTextMapping (b , fieldName , model .getInferenceEntityId (), null , newChunkingSettings , newIndexOptions ))
735743 );
736- assertSemanticTextField (mapperService , fieldName , false , newChunkingSettings , newIndexOptions );
744+ assertSemanticTextField (mapperService , fieldName , true , newChunkingSettings , newIndexOptions );
737745 }
738746 }
739747
@@ -926,27 +934,29 @@ public void testSuccessfulParse() throws IOException {
926934 model1 .getInferenceEntityId (),
927935 setSearchInferenceId ? searchInferenceId : null ,
928936 chunkingSettings ,
929- indexOptions
937+ indexOptions ,
938+ new MinimalServiceSettings (model1 )
930939 );
931940 addSemanticTextMapping (
932941 b ,
933942 fieldName2 ,
934943 model2 .getInferenceEntityId (),
935944 setSearchInferenceId ? searchInferenceId : null ,
936945 chunkingSettings ,
937- indexOptions
946+ indexOptions ,
947+ new MinimalServiceSettings (model2 )
938948 );
939949 });
940950
941951 MapperService mapperService = createMapperService (mapping , useLegacyFormat );
942- assertSemanticTextField (mapperService , fieldName1 , false , null , indexOptions );
952+ assertSemanticTextField (mapperService , fieldName1 , true , null , indexOptions );
943953 assertInferenceEndpoints (
944954 mapperService ,
945955 fieldName1 ,
946956 model1 .getInferenceEntityId (),
947957 setSearchInferenceId ? searchInferenceId : model1 .getInferenceEntityId ()
948958 );
949- assertSemanticTextField (mapperService , fieldName2 , false , null , indexOptions );
959+ assertSemanticTextField (mapperService , fieldName2 , true , null , indexOptions );
950960 assertInferenceEndpoints (
951961 mapperService ,
952962 fieldName2 ,
@@ -1207,7 +1217,14 @@ public void testModelSettingsRequiredWithChunks() throws IOException {
12071217 );
12081218
12091219 MapperService mapperService = createMapperService (
1210- mapping (b -> addSemanticTextMapping (b , "field" , model .getInferenceEntityId (), null , chunkingSettings , indexOptions )),
1220+ mapping (b -> addSemanticTextMapping (
1221+ b ,
1222+ "field" ,
1223+ model .getInferenceEntityId (),
1224+ null ,
1225+ chunkingSettings ,
1226+ indexOptions
1227+ )),
12111228 useLegacyFormat
12121229 );
12131230 SourceToParse source = source (b -> addSemanticTextInferenceResults (useLegacyFormat , b , List .of (inferenceResults )));
@@ -1709,18 +1726,33 @@ protected void assertExistsQuery(MappedFieldType fieldType, Query query, LuceneD
17091726 // Until a doc is indexed, the query is rewritten as match no docs
17101727 assertThat (query , instanceOf (MatchNoDocsQuery .class ));
17111728 }
1712-
17131729 private static void addSemanticTextMapping (
17141730 XContentBuilder mappingBuilder ,
17151731 String fieldName ,
17161732 String inferenceId ,
17171733 String searchInferenceId ,
17181734 ChunkingSettings chunkingSettings ,
17191735 SemanticTextIndexOptions indexOptions
1736+ ) throws IOException {
1737+ addSemanticTextMapping (mappingBuilder , fieldName , inferenceId , searchInferenceId , chunkingSettings , indexOptions , null );
1738+ }
1739+
1740+ private static void addSemanticTextMapping (
1741+ XContentBuilder mappingBuilder ,
1742+ String fieldName ,
1743+ String inferenceId ,
1744+ String searchInferenceId ,
1745+ ChunkingSettings chunkingSettings ,
1746+ SemanticTextIndexOptions indexOptions ,
1747+ MinimalServiceSettings modelSettings
17201748 ) throws IOException {
17211749 mappingBuilder .startObject (fieldName );
17221750 mappingBuilder .field ("type" , SemanticTextFieldMapper .CONTENT_TYPE );
17231751 mappingBuilder .field ("inference_id" , inferenceId );
1752+ if (modelSettings != null ) {
1753+ mappingBuilder .field ("model_settings" );
1754+ modelSettings .toXContent (mappingBuilder , null );
1755+ }
17241756 if (searchInferenceId != null ) {
17251757 mappingBuilder .field ("search_inference_id" , searchInferenceId );
17261758 }
0 commit comments