@@ -475,8 +475,13 @@ public void testRecoverySourceWithSyntheticSource() throws IOException {
475475 MapperService mapperService = createMapperService (settings , topMapping (b -> {}));
476476 DocumentMapper docMapper = mapperService .documentMapper ();
477477 ParsedDocument doc = docMapper .parse (source (b -> b .field ("field1" , "value1" )));
478- assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
479- assertThat (doc .rootDoc ().getField ("_recovery_source" ).binaryValue (), equalTo (new BytesRef ("{\" field1\" :\" value1\" }" )));
478+ if (IndexSettings .RECOVERY_USE_SYNTHETIC_SOURCE .isEnabled () == false ) {
479+ // TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
480+ assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
481+ assertThat (doc .rootDoc ().getField ("_recovery_source" ).binaryValue (), equalTo (new BytesRef ("{\" field1\" :\" value1\" }" )));
482+ } else {
483+ assertNull (doc .rootDoc ().getField ("_recovery_source" ));
484+ }
480485 }
481486 {
482487 Settings settings = Settings .builder ()
@@ -507,8 +512,16 @@ public void testRecoverySourceWithLogs() throws IOException {
507512 MapperService mapperService = createMapperService (settings , mapping (b -> {}));
508513 DocumentMapper docMapper = mapperService .documentMapper ();
509514 ParsedDocument doc = docMapper .parse (source (b -> { b .field ("@timestamp" , "2012-02-13" ); }));
510- assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
511- assertThat (doc .rootDoc ().getField ("_recovery_source" ).binaryValue (), equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" }" )));
515+ if (IndexSettings .RECOVERY_USE_SYNTHETIC_SOURCE .isEnabled () == false ) {
516+ // TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
517+ assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
518+ assertThat (
519+ doc .rootDoc ().getField ("_recovery_source" ).binaryValue (),
520+ equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" }" ))
521+ );
522+ } else {
523+ assertNull (doc .rootDoc ().getField ("_recovery_source" ));
524+ }
512525 }
513526 {
514527 Settings settings = Settings .builder ()
@@ -701,8 +714,16 @@ public void testRecoverySourceWithLogsCustom() throws IOException {
701714 MapperService mapperService = createMapperService (settings , mappings );
702715 DocumentMapper docMapper = mapperService .documentMapper ();
703716 ParsedDocument doc = docMapper .parse (source (b -> { b .field ("@timestamp" , "2012-02-13" ); }));
704- assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
705- assertThat (doc .rootDoc ().getField ("_recovery_source" ).binaryValue (), equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" }" )));
717+ if (IndexSettings .RECOVERY_USE_SYNTHETIC_SOURCE .isEnabled () == false ) {
718+ // TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
719+ assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
720+ assertThat (
721+ doc .rootDoc ().getField ("_recovery_source" ).binaryValue (),
722+ equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" }" ))
723+ );
724+ } else {
725+ assertNull (doc .rootDoc ().getField ("_recovery_source" ));
726+ }
706727 }
707728 {
708729 Settings settings = Settings .builder ()
@@ -728,11 +749,16 @@ public void testRecoverySourceWithTimeSeries() throws IOException {
728749 }));
729750 DocumentMapper docMapper = mapperService .documentMapper ();
730751 ParsedDocument doc = docMapper .parse (source ("123" , b -> b .field ("@timestamp" , "2012-02-13" ).field ("field" , "value1" ), null ));
731- assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
732- assertThat (
733- doc .rootDoc ().getField ("_recovery_source" ).binaryValue (),
734- equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" ,\" field\" :\" value1\" }" ))
735- );
752+ if (IndexSettings .RECOVERY_USE_SYNTHETIC_SOURCE .isEnabled () == false ) {
753+ // TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
754+ assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
755+ assertThat (
756+ doc .rootDoc ().getField ("_recovery_source" ).binaryValue (),
757+ equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" ,\" field\" :\" value1\" }" ))
758+ );
759+ } else {
760+ assertNull (doc .rootDoc ().getField ("_recovery_source" ));
761+ }
736762 }
737763 {
738764 Settings settings = Settings .builder ()
@@ -776,11 +802,16 @@ public void testRecoverySourceWithTimeSeriesCustom() throws IOException {
776802 MapperService mapperService = createMapperService (settings , mappings );
777803 DocumentMapper docMapper = mapperService .documentMapper ();
778804 ParsedDocument doc = docMapper .parse (source ("123" , b -> b .field ("@timestamp" , "2012-02-13" ).field ("field" , "value1" ), null ));
779- assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
780- assertThat (
781- doc .rootDoc ().getField ("_recovery_source" ).binaryValue (),
782- equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" ,\" field\" :\" value1\" }" ))
783- );
805+ if (IndexSettings .RECOVERY_USE_SYNTHETIC_SOURCE .isEnabled () == false ) {
806+ // TODO: remove this if branch when removing the 'index_recovery_use_synthetic_source' feature flag
807+ assertNotNull (doc .rootDoc ().getField ("_recovery_source" ));
808+ assertThat (
809+ doc .rootDoc ().getField ("_recovery_source" ).binaryValue (),
810+ equalTo (new BytesRef ("{\" @timestamp\" :\" 2012-02-13\" ,\" field\" :\" value1\" }" ))
811+ );
812+ } else {
813+ assertNull (doc .rootDoc ().getField ("_recovery_source" ));
814+ }
784815 }
785816 {
786817 Settings settings = Settings .builder ()
0 commit comments