Skip to content

Commit

Permalink
fix: recover source field unvailable with synthetic source
Browse files Browse the repository at this point in the history
  • Loading branch information
salvatore-campagna committed Jan 10, 2025
1 parent fff1fe4 commit 8a6418a
Showing 1 changed file with 5 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ public void testRecoverySourceWithSyntheticSource() throws IOException {
MapperService mapperService = createMapperService(settings, topMapping(b -> {}));
DocumentMapper docMapper = mapperService.documentMapper();
ParsedDocument doc = docMapper.parse(source(b -> b.field("field1", "value1")));
assertNotNull(doc.rootDoc().getField("_recovery_source"));
assertThat(doc.rootDoc().getField("_recovery_source").binaryValue(), equalTo(new BytesRef("{\"field1\":\"value1\"}")));
assertNull(doc.rootDoc().getField("_recovery_source"));
}
{
Settings settings = Settings.builder()
Expand Down Expand Up @@ -507,8 +506,7 @@ public void testRecoverySourceWithLogs() throws IOException {
MapperService mapperService = createMapperService(settings, mapping(b -> {}));
DocumentMapper docMapper = mapperService.documentMapper();
ParsedDocument doc = docMapper.parse(source(b -> { b.field("@timestamp", "2012-02-13"); }));
assertNotNull(doc.rootDoc().getField("_recovery_source"));
assertThat(doc.rootDoc().getField("_recovery_source").binaryValue(), equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\"}")));
assertNull(doc.rootDoc().getField("_recovery_source"));
}
{
Settings settings = Settings.builder()
Expand Down Expand Up @@ -701,8 +699,7 @@ public void testRecoverySourceWithLogsCustom() throws IOException {
MapperService mapperService = createMapperService(settings, mappings);
DocumentMapper docMapper = mapperService.documentMapper();
ParsedDocument doc = docMapper.parse(source(b -> { b.field("@timestamp", "2012-02-13"); }));
assertNotNull(doc.rootDoc().getField("_recovery_source"));
assertThat(doc.rootDoc().getField("_recovery_source").binaryValue(), equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\"}")));
assertNull(doc.rootDoc().getField("_recovery_source"));
}
{
Settings settings = Settings.builder()
Expand All @@ -728,11 +725,7 @@ public void testRecoverySourceWithTimeSeries() throws IOException {
}));
DocumentMapper docMapper = mapperService.documentMapper();
ParsedDocument doc = docMapper.parse(source("123", b -> b.field("@timestamp", "2012-02-13").field("field", "value1"), null));
assertNotNull(doc.rootDoc().getField("_recovery_source"));
assertThat(
doc.rootDoc().getField("_recovery_source").binaryValue(),
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\",\"field\":\"value1\"}"))
);
assertNull(doc.rootDoc().getField("_recovery_source"));
}
{
Settings settings = Settings.builder()
Expand Down Expand Up @@ -776,11 +769,7 @@ public void testRecoverySourceWithTimeSeriesCustom() throws IOException {
MapperService mapperService = createMapperService(settings, mappings);
DocumentMapper docMapper = mapperService.documentMapper();
ParsedDocument doc = docMapper.parse(source("123", b -> b.field("@timestamp", "2012-02-13").field("field", "value1"), null));
assertNotNull(doc.rootDoc().getField("_recovery_source"));
assertThat(
doc.rootDoc().getField("_recovery_source").binaryValue(),
equalTo(new BytesRef("{\"@timestamp\":\"2012-02-13\",\"field\":\"value1\"}"))
);
assertNull(doc.rootDoc().getField("_recovery_source"));
}
{
Settings settings = Settings.builder()
Expand Down

0 comments on commit 8a6418a

Please sign in to comment.