@@ -920,19 +920,27 @@ public void testDenseVectorDynamicMapping() throws Exception {
920920
921921 client ().index (
922922 new IndexRequest ("test" ).source ("vector_int8" , Randomness .get ().doubles (BBQ_DIMS_DEFAULT_THRESHOLD - 1 , 0.0 , 5.0 ).toArray ())
923+ .setRefreshPolicy (WriteRequest .RefreshPolicy .IMMEDIATE )
923924 ).get ();
924925 client ().index (
925926 new IndexRequest ("test" ).source ("vector_bbq" , Randomness .get ().doubles (BBQ_DIMS_DEFAULT_THRESHOLD , 0.0 , 5.0 ).toArray ())
927+ .setRefreshPolicy (WriteRequest .RefreshPolicy .IMMEDIATE )
926928 ).get ();
927- Map <String , Object > mappings = indicesAdmin ().prepareGetMappings (TEST_REQUEST_TIMEOUT , "test" )
928- .get ()
929- .mappings ()
930- .get ("test" )
931- .sourceAsMap ();
932- assertTrue (new WriteField ("properties.vector_int8" , () -> mappings ).exists ());
933- assertTrue (new WriteField ("properties.vector_int8.index_options.type" , () -> mappings ).get (null ).toString ().equals ("int8_hnsw" ));
934- assertTrue (new WriteField ("properties.vector_bbq" , () -> mappings ).exists ());
935- assertTrue (new WriteField ("properties.vector_bbq.index_options.type" , () -> mappings ).get (null ).toString ().equals ("bbq_hnsw" ));
929+
930+ assertBusy (() -> {
931+ Map <String , Object > mappings = indicesAdmin ().prepareGetMappings (TEST_REQUEST_TIMEOUT , "test" )
932+ .get ()
933+ .mappings ()
934+ .get ("test" )
935+ .sourceAsMap ();
936+
937+ assertTrue (new WriteField ("properties.vector_int8" , () -> mappings ).exists ());
938+ assertTrue (
939+ new WriteField ("properties.vector_int8.index_options.type" , () -> mappings ).get (null ).toString ().equals ("int8_hnsw" )
940+ );
941+ assertTrue (new WriteField ("properties.vector_bbq" , () -> mappings ).exists ());
942+ assertTrue (new WriteField ("properties.vector_bbq.index_options.type" , () -> mappings ).get (null ).toString ().equals ("bbq_hnsw" ));
943+ });
936944 }
937945
938946 public void testBBQDynamicMappingWhenFirstIngestingDoc () throws Exception {
@@ -954,14 +962,19 @@ public void testBBQDynamicMappingWhenFirstIngestingDoc() throws Exception {
954962 assertTrue (new WriteField ("properties.vector" , () -> mappings ).exists ());
955963 assertFalse (new WriteField ("properties.vector.index_options.type" , () -> mappings ).exists ());
956964
957- client ().index (new IndexRequest ("test" ).source ("vector" , Randomness .get ().doubles (BBQ_DIMS_DEFAULT_THRESHOLD , 0.0 , 5.0 ).toArray ()))
958- .get ();
959- Map <String , Object > updatedMappings = indicesAdmin ().prepareGetMappings (TEST_REQUEST_TIMEOUT , "test" )
960- .get ()
961- .mappings ()
962- .get ("test" )
963- .sourceAsMap ();
964- assertTrue (new WriteField ("properties.vector" , () -> updatedMappings ).exists ());
965- assertTrue (new WriteField ("properties.vector.index_options.type" , () -> updatedMappings ).get (null ).toString ().equals ("bbq_hnsw" ));
965+ client ().index (
966+ new IndexRequest ("test" ).source ("vector" , Randomness .get ().doubles (BBQ_DIMS_DEFAULT_THRESHOLD , 0.0 , 5.0 ).toArray ())
967+ .setRefreshPolicy (WriteRequest .RefreshPolicy .IMMEDIATE )
968+ ).get ();
969+
970+ assertBusy (() -> {
971+ Map <String , Object > updatedMappings = indicesAdmin ().prepareGetMappings (TEST_REQUEST_TIMEOUT , "test" )
972+ .get ()
973+ .mappings ()
974+ .get ("test" )
975+ .sourceAsMap ();
976+ assertTrue (new WriteField ("properties.vector" , () -> updatedMappings ).exists ());
977+ assertTrue (new WriteField ("properties.vector.index_options.type" , () -> updatedMappings ).get ("" ).toString ().equals ("bbq_hnsw" ));
978+ });
966979 }
967980}
0 commit comments