2525import java .util .Map ;
2626import java .util .Set ;
2727
28+ import static org .elasticsearch .index .IndexSettings .INDEX_MAPPER_SOURCE_MODE_SETTING ;
29+ import static org .elasticsearch .index .mapper .SourceFieldMapper .Mode .SYNTHETIC ;
2830import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
2931
3032public class DenseVectorFieldTypeIT extends AbstractEsqlIntegTestCase {
@@ -42,22 +44,26 @@ public class DenseVectorFieldTypeIT extends AbstractEsqlIntegTestCase {
4244
4345 private final String indexType ;
4446 private final boolean index ;
45- private int numDims ;
46- private int numDocs ;
47+ private final boolean synthetic ;
4748
4849 @ ParametersFactory
4950 public static Iterable <Object []> parameters () throws Exception {
5051 List <Object []> params = new ArrayList <>();
52+ // Indexed field types
5153 for (String indexType : DENSE_VECTOR_INDEX_TYPES ) {
52- params .add (new Object [] { indexType , true });
54+ params .add (new Object [] { indexType , true , false });
5355 }
54- params .add (new Object [] { null , false });
56+ // No indexing
57+ params .add (new Object [] { null , false , false });
58+ // No indexing, synthetic source
59+ params .add (new Object [] { null , false , true });
5560 return params ;
5661 }
5762
58- public DenseVectorFieldTypeIT (@ Name ("indexType" ) String indexType , @ Name ("index" ) boolean index ) {
63+ public DenseVectorFieldTypeIT (@ Name ("indexType" ) String indexType , @ Name ("index" ) boolean index , @ Name ( "synthetic" ) boolean synthetic ) {
5964 this .indexType = indexType ;
6065 this .index = index ;
66+ this .synthetic = synthetic ;
6167 }
6268
6369 private final Map <Integer , List <Float >> indexedVectors = new HashMap <>();
@@ -141,18 +147,21 @@ public void setup() throws IOException {
141147 mapping .startObject ("index_options" ).field ("type" , indexType ).endObject ();
142148 }
143149 mapping .endObject ().endObject ().endObject ();
144- Settings settings = Settings .builder ()
150+ Settings . Builder settingsBuilder = Settings .builder ()
145151 .put (IndexMetadata .SETTING_NUMBER_OF_REPLICAS , 0 )
146- .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , randomIntBetween (1 , 5 ))
147- .build ();
152+ .put (IndexMetadata .SETTING_NUMBER_OF_SHARDS , randomIntBetween (1 , 5 ));
153+ if (synthetic ) {
154+ settingsBuilder .put (INDEX_MAPPER_SOURCE_MODE_SETTING .getKey (), SYNTHETIC );
155+ }
156+
148157 var CreateRequest = client .prepareCreate (indexName )
149158 .setSettings (Settings .builder ().put ("index.number_of_shards" , 1 ))
150159 .setMapping (mapping )
151- .setSettings (settings );
160+ .setSettings (settingsBuilder . build () );
152161 assertAcked (CreateRequest );
153162
154- numDims = randomIntBetween (32 , 64 ) * 2 ; // min 64, even number
155- numDocs = randomIntBetween (10 , 100 );
163+ int numDims = randomIntBetween (32 , 64 ) * 2 ; // min 64, even number
164+ int numDocs = randomIntBetween (10 , 100 );
156165 IndexRequestBuilder [] docs = new IndexRequestBuilder [numDocs ];
157166 for (int i = 0 ; i < numDocs ; i ++) {
158167 List <Float > vector = new ArrayList <>(numDims );
0 commit comments