3030import java .nio .file .Path ;
3131import java .util .Collection ;
3232import java .util .List ;
33+ import java .util .Map ;
3334import java .util .OptionalLong ;
3435import java .util .stream .IntStream ;
3536
3637import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertAcked ;
3738import static org .elasticsearch .test .hamcrest .ElasticsearchAssertions .assertHitCount ;
39+ import static org .hamcrest .Matchers .equalTo ;
40+ import static org .hamcrest .Matchers .is ;
3841
3942@ LuceneTestCase .SuppressCodecs ("*" ) // only use our own codecs
4043public class DirectIOIT extends ESIntegTestCase {
@@ -64,6 +67,7 @@ protected Collection<Class<? extends Plugin>> nodePlugins() {
6467 }
6568
6669 private void indexVectors () {
70+ String type = randomFrom ("bbq_flat" , "bbq_hnsw" );
6771 assertAcked (
6872 prepareCreate ("foo-vectors" ).setSettings (Settings .builder ().put (InternalSettingsPlugin .USE_COMPOUND_FILE .getKey (), false ))
6973 .setMapping ("""
@@ -76,19 +80,27 @@ private void indexVectors() {
7680 "index": true,
7781 "similarity": "l2_norm",
7882 "index_options": {
79- "type": "bbq_flat "
83+ "type": "%type% "
8084 }
8185 }
8286 }
8387 }
84- """ )
88+ """ . replace ( "%type%" , type ) )
8589 );
8690 ensureGreen ("foo-vectors" );
8791
8892 for (int i = 0 ; i < 1000 ; i ++) {
8993 indexDoc ("foo-vectors" , Integer .toString (i ), "fooVector" , IntStream .range (0 , 64 ).mapToDouble (d -> randomFloat ()).toArray ());
9094 }
9195 refresh ();
96+ assertBBQIndexType (type ); // test assertion to ensure that the correct index type is being used
97+ }
98+
99+ @ SuppressWarnings ("unchecked" )
100+ static void assertBBQIndexType (String type ) {
101+ var response = indicesAdmin ().prepareGetFieldMappings ("foo-vectors" ).setFields ("fooVector" ).get ();
102+ var map = (Map <String , Object >) response .fieldMappings ("foo-vectors" , "fooVector" ).sourceAsMap ().get ("fooVector" );
103+ assertThat ((String ) ((Map <String , Object >) map .get ("index_options" )).get ("type" ), is (equalTo (type )));
92104 }
93105
94106 @ TestLogging (value = "org.elasticsearch.index.store.FsDirectoryFactory:DEBUG" , reason = "to capture trace logging for direct IO" )
0 commit comments