|
@@ -40,7 +40,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -98,10 +98,10 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "non-existing-field")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
- .startObject("@timestamp")
|
|
|
+ .startObject("my_date_field")
|
|
|
.field("type", "date")
|
|
|
.endObject()
|
|
|
.endObject()
|
|
@@ -114,7 +114,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
() -> createIndex("test").mapperService()
|
|
|
.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE)
|
|
|
);
|
|
|
- assertThat(e.getMessage(), equalTo("the configured timestamp field [non-existing-field] does not exist"));
|
|
|
+ assertThat(e.getMessage(), equalTo("data stream timestamp field [@timestamp] does not exist"));
|
|
|
}
|
|
|
|
|
|
public void testValidateInvalidFieldType() throws IOException {
|
|
@@ -123,7 +123,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -141,7 +141,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
);
|
|
|
assertThat(
|
|
|
e.getMessage(),
|
|
|
- equalTo("the configured timestamp field [@timestamp] is of type [keyword], but [date,date_nanos] is expected")
|
|
|
+ equalTo("data stream timestamp field [@timestamp] is of type [keyword], but [date,date_nanos] is expected")
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -151,7 +151,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -168,7 +168,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
() -> createIndex("test").mapperService()
|
|
|
.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE)
|
|
|
);
|
|
|
- assertThat(e.getMessage(), equalTo("the configured timestamp field [@timestamp] is not indexed"));
|
|
|
+ assertThat(e.getMessage(), equalTo("data stream timestamp field [@timestamp] is not indexed"));
|
|
|
}
|
|
|
|
|
|
public void testValidateNotDocValues() throws IOException {
|
|
@@ -177,7 +177,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -194,7 +194,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
() -> createIndex("test").mapperService()
|
|
|
.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE)
|
|
|
);
|
|
|
- assertThat(e.getMessage(), equalTo("the configured timestamp field [@timestamp] doesn't have doc values"));
|
|
|
+ assertThat(e.getMessage(), equalTo("data stream timestamp field [@timestamp] doesn't have doc values"));
|
|
|
}
|
|
|
|
|
|
public void testValidateNullValue() throws IOException {
|
|
@@ -203,7 +203,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -220,7 +220,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
() -> createIndex("test").mapperService()
|
|
|
.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE)
|
|
|
);
|
|
|
- assertThat(e.getMessage(), equalTo("the configured timestamp field [@timestamp] has disallowed [null_value] attribute specified"));
|
|
|
+ assertThat(e.getMessage(), equalTo("data stream timestamp field [@timestamp] has disallowed [null_value] attribute specified"));
|
|
|
}
|
|
|
|
|
|
public void testValidateIgnoreMalformed() throws IOException {
|
|
@@ -229,7 +229,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -248,7 +248,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
);
|
|
|
assertThat(
|
|
|
e.getMessage(),
|
|
|
- equalTo("the configured timestamp field [@timestamp] has disallowed [ignore_malformed] attribute specified")
|
|
|
+ equalTo("data stream timestamp field [@timestamp] has disallowed [ignore_malformed] attribute specified")
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -258,7 +258,7 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
.startObject()
|
|
|
.startObject("type")
|
|
|
.startObject("_data_stream_timestamp")
|
|
|
- .field("path", "@timestamp")
|
|
|
+ .field("enabled", true)
|
|
|
.endObject()
|
|
|
.startObject("properties")
|
|
|
.startObject("@timestamp")
|
|
@@ -275,63 +275,21 @@ public class DataStreamTimestampFieldMapperTests extends ESSingleNodeTestCase {
|
|
|
() -> createIndex("test").mapperService()
|
|
|
.merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE)
|
|
|
);
|
|
|
- assertThat(e.getMessage(), equalTo("the configured timestamp field [@timestamp] has disallowed attributes: [store]"));
|
|
|
+ assertThat(e.getMessage(), equalTo("data stream timestamp field [@timestamp] has disallowed attributes: [store]"));
|
|
|
}
|
|
|
|
|
|
public void testCannotUpdateTimestampField() throws IOException {
|
|
|
DocumentMapperParser parser = createIndex("test").mapperService().documentMapperParser();
|
|
|
String mapping1 =
|
|
|
- "{\"type\":{\"_data_stream_timestamp\":{\"path\":\"@timestamp\"}, \"properties\": {\"@timestamp\": {\"type\": \"date\"}}}}}";
|
|
|
- String mapping2 = "{\"type\":{\"_data_stream_timestamp\":{\"path\":\"@timestamp2\"}, \"properties\": {\"@timestamp2\": "
|
|
|
+ "{\"type\":{\"_data_stream_timestamp\":{\"enabled\":false}, \"properties\": {\"@timestamp\": {\"type\": \"date\"}}}}}";
|
|
|
+ String mapping2 = "{\"type\":{\"_data_stream_timestamp\":{\"enabled\":true}, \"properties\": {\"@timestamp2\": "
|
|
|
+ "{\"type\": \"date\"},\"@timestamp\": {\"type\": \"date\"}}}})";
|
|
|
- assertConflicts(mapping1, mapping2, parser, "cannot update path setting for [_data_stream_timestamp]");
|
|
|
+ assertConflicts(mapping1, mapping2, parser, "cannot update enabled setting for [_data_stream_timestamp]");
|
|
|
|
|
|
mapping1 = "{\"type\":{\"properties\":{\"@timestamp\": {\"type\": \"date\"}}}}}";
|
|
|
- mapping2 = "{\"type\":{\"_data_stream_timestamp\":{\"path\":\"@timestamp2\"}, \"properties\": "
|
|
|
+ mapping2 = "{\"type\":{\"_data_stream_timestamp\":{\"enabled\":true}, \"properties\": "
|
|
|
+ "{\"@timestamp2\": {\"type\": \"date\"},\"@timestamp\": {\"type\": \"date\"}}}})";
|
|
|
- assertConflicts(mapping1, mapping2, parser, "cannot update path setting for [_data_stream_timestamp]");
|
|
|
- }
|
|
|
-
|
|
|
- public void testDifferentTSField() throws IOException {
|
|
|
- String mapping = "{\n"
|
|
|
- + " \"_data_stream_timestamp\": {\n"
|
|
|
- + " \"path\": \"event.my_timestamp\"\n"
|
|
|
- + " },\n"
|
|
|
- + " \"properties\": {\n"
|
|
|
- + " \"event\": {\n"
|
|
|
- + " \"properties\": {\n"
|
|
|
- + " \"my_timestamp\": {\n"
|
|
|
- + " \"type\": \"date\""
|
|
|
- + " }\n"
|
|
|
- + " }\n"
|
|
|
- + " }\n"
|
|
|
- + " }\n"
|
|
|
- + " }";
|
|
|
- DocumentMapper docMapper = createIndex("test").mapperService()
|
|
|
- .merge("type", new CompressedXContent(mapping), MapperService.MergeReason.MAPPING_UPDATE);
|
|
|
-
|
|
|
- ParsedDocument doc = docMapper.parse(
|
|
|
- new SourceToParse(
|
|
|
- "test",
|
|
|
- "1",
|
|
|
- BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("event.my_timestamp", "2020-12-12").endObject()),
|
|
|
- XContentType.JSON
|
|
|
- )
|
|
|
- );
|
|
|
- assertThat(doc.rootDoc().getFields("event.my_timestamp").length, equalTo(2));
|
|
|
-
|
|
|
- Exception e = expectThrows(
|
|
|
- MapperException.class,
|
|
|
- () -> docMapper.parse(
|
|
|
- new SourceToParse(
|
|
|
- "test",
|
|
|
- "1",
|
|
|
- BytesReference.bytes(XContentFactory.jsonBuilder().startObject().field("event.timestamp", "2020-12-12").endObject()),
|
|
|
- XContentType.JSON
|
|
|
- )
|
|
|
- )
|
|
|
- );
|
|
|
- assertThat(e.getCause().getMessage(), equalTo("data stream timestamp field [event.my_timestamp] is missing"));
|
|
|
+ assertConflicts(mapping1, mapping2, parser, "cannot update enabled setting for [_data_stream_timestamp]");
|
|
|
}
|
|
|
|
|
|
}
|