@@ -235,4 +235,61 @@ public void testReindexIncludeVectors() throws Exception {
235235 searchResponse .decRef ();
236236 }
237237 }
238+
239+ public void testReindexAutoIncludeVectors () throws Exception {
240+ var resp1 = prepareCreate ("test" ).setSettings (
241+ Settings .builder ().put (IndexSettings .INDEX_MAPPING_EXCLUDE_SOURCE_VECTORS_SETTING .getKey (), false ).build ()
242+ ).setMapping (
243+ Map .of (
244+ "_source" ,
245+ Map .of ("enabled" , true , "excludes" , List .of ("foo" , "bar" )),
246+ "properties" ,
247+ Map .of (
248+ "foo" , Map .of ("type" , "dense_vector" , "similarity" , "l2_norm" ),
249+ "bar" , Map .of ("type" , "sparse_vector" , "store" , true )
250+ )
251+ )
252+ ).get ();
253+ assertAcked (resp1 );
254+
255+ var resp2 = prepareCreate ("test_reindex" ).setSettings (
256+ Settings .builder ().put (IndexSettings .INDEX_MAPPING_EXCLUDE_SOURCE_VECTORS_SETTING .getKey (), false ).build ()
257+ ).setMapping (
258+ Map .of (
259+ "_source" ,
260+ Map .of ("enabled" , true , "excludes" , List .of ("foo" , "bar" )),
261+ "properties" ,
262+ Map .of (
263+ "foo" , Map .of ("type" , "dense_vector" , "similarity" , "l2_norm" ),
264+ "bar" , Map .of ("type" , "sparse_vector" , "store" , true )
265+ )
266+ )
267+ ).get ();
268+ assertAcked (resp2 );
269+
270+ indexRandom (
271+ true ,
272+ prepareIndex ("test" ).setId ("1" ).setSource ("foo" , List .of (3f , 2f , 1.5f ), "bar" , Map .of ("token_1" , 4f , "token_2" , 7f ))
273+ );
274+
275+ // Copy all the docs
276+ ReindexRequestBuilder copy = reindex ().source ("test" ).destination ("test_reindex" ).refresh (true );
277+ var reindexResponse = copy .get ();
278+ assertThat (reindexResponse , matcher ().created (1 ));
279+
280+ var searchResponse = prepareSearch ("test_reindex" ).get ();
281+ try {
282+ assertThat (searchResponse .getHits ().getTotalHits ().value (), equalTo (1L ));
283+ assertThat (searchResponse .getHits ().getHits ().length , equalTo (1 ));
284+ var sourceMap = searchResponse .getHits ().getAt (0 ).getSourceAsMap ();
285+ assertThat (sourceMap .get ("foo" ), anyOf (equalTo (List .of (3f , 2f , 1.5f )), equalTo (List .of (3d , 2d , 1.5d ))));
286+ assertThat (
287+ sourceMap .get ("bar" ),
288+ anyOf (equalTo (Map .of ("token_1" , 4f , "token_2" , 7f )), equalTo (Map .of ("token_1" , 4d , "token_2" , 7d )))
289+ );
290+ } finally {
291+ searchResponse .decRef ();
292+ }
293+ }
294+
238295}
0 commit comments