@@ -123,13 +123,40 @@ public void testValidateIndexOptionsWithBasicLicense() throws Exception {
123123 safeGet (prepareCreate (INDEX_NAME ).setMapping (generateMapping (inferenceFieldName , inferenceId , indexOptions )).execute ())
124124 );
125125
126- final Map <String , Object > expectedFieldMapping = generateExpectedFieldMapping (inferenceId , inferenceFieldName , indexOptions );
126+ final Map <String , Object > expectedFieldMapping = generateExpectedFieldMapping (inferenceFieldName , inferenceId , indexOptions );
127127 var getFieldMappingsResponse = safeGet (
128128 client ().execute (GetFieldMappingsAction .INSTANCE , new GetFieldMappingsRequest ().indices (INDEX_NAME ).fields (inferenceFieldName ))
129129 );
130130 assertThat (getFieldMappingsResponse .fieldMappings (INDEX_NAME , inferenceFieldName ).sourceAsMap (), equalTo (expectedFieldMapping ));
131131 }
132132
133+ public void testSetDefaultBBQIndexOptionsWithBasicLicense () throws Exception {
134+ final String inferenceId = "test-inference-id-2" ;
135+ final String inferenceFieldName = "inference_field" ;
136+ createInferenceEndpoint (TaskType .TEXT_EMBEDDING , inferenceId , BBQ_COMPATIBLE_SERVICE_SETTINGS );
137+
138+ setLicense ("basic" );
139+ assertAcked (safeGet (prepareCreate (INDEX_NAME ).setMapping (generateMapping (inferenceFieldName , inferenceId , null )).execute ()));
140+
141+ final Map <String , Object > expectedFieldMapping = generateExpectedFieldMapping (
142+ inferenceFieldName ,
143+ inferenceId ,
144+ SemanticTextFieldMapper .defaultBbqHnswDenseVectorIndexOptions ()
145+ );
146+ var getFieldMappingsResponse = safeGet (
147+ client ().execute (
148+ GetFieldMappingsAction .INSTANCE ,
149+ new GetFieldMappingsRequest ().indices (INDEX_NAME ).fields (inferenceFieldName ).includeDefaults (true )
150+ )
151+ );
152+
153+ // Filter out null/empty values from params we didn't set to make comparison easier
154+ Map <String , Object > actualFieldMappings = filterNullOrEmptyValues (
155+ getFieldMappingsResponse .fieldMappings (INDEX_NAME , inferenceFieldName ).sourceAsMap ()
156+ );
157+ assertThat (actualFieldMappings , equalTo (expectedFieldMapping ));
158+ }
159+
133160 private void createInferenceEndpoint (TaskType taskType , String inferenceId , Map <String , Object > serviceSettings ) throws IOException {
134161 final String service = switch (taskType ) {
135162 case TEXT_EMBEDDING -> TestDenseInferenceServiceExtension .TestInferenceService .NAME ;
@@ -207,6 +234,27 @@ private static Map<String, Object> generateExpectedFieldMapping(
207234 return expectedFieldMapping ;
208235 }
209236
237+ @ SuppressWarnings ("unchecked" )
238+ private static Map <String , Object > filterNullOrEmptyValues (Map <String , Object > map ) {
239+ Map <String , Object > filteredMap = new HashMap <>();
240+ for (var entry : map .entrySet ()) {
241+ Object value = entry .getValue ();
242+ if (entry .getValue () instanceof Map <?, ?> mapValue ) {
243+ if (mapValue .isEmpty ()) {
244+ continue ;
245+ }
246+
247+ value = filterNullOrEmptyValues ((Map <String , Object >) mapValue );
248+ }
249+
250+ if (value != null ) {
251+ filteredMap .put (entry .getKey (), value );
252+ }
253+ }
254+
255+ return filteredMap ;
256+ }
257+
210258 private static void setLicense (String type ) throws Exception {
211259 if (type .equals ("basic" )) {
212260 assertAcked (
0 commit comments