@@ -41,6 +41,17 @@ public void testEventDataset() throws Exception {
41
41
assertThat (ingestDocument .getFieldValue ("event.dataset" , String .class ), equalTo ("foo" ));
42
42
}
43
43
44
+ public void testEventDatasetDottedFieldName () throws Exception {
45
+ IngestDocument ingestDocument = createIngestDocument ("logs-generic-default" );
46
+ ingestDocument .getCtxMap ().put ("event.dataset" , "foo" );
47
+
48
+ RerouteProcessor processor = createRerouteProcessor (List .of ("{{event.dataset}}" ), List .of ());
49
+ processor .execute (ingestDocument );
50
+ assertDataSetFields (ingestDocument , "logs" , "foo" , "default" );
51
+ assertThat (ingestDocument .getCtxMap ().get ("event.dataset" ), equalTo ("foo" ));
52
+ assertFalse (ingestDocument .getCtxMap ().containsKey ("event" ));
53
+ }
54
+
44
55
public void testNoDataset () throws Exception {
45
56
IngestDocument ingestDocument = createIngestDocument ("logs-generic-default" );
46
57
ingestDocument .setFieldValue ("ds" , "foo" );
@@ -81,6 +92,17 @@ public void testDataStreamFieldsFromDocument() throws Exception {
81
92
assertDataSetFields (ingestDocument , "logs" , "foo" , "bar" );
82
93
}
83
94
95
+ public void testDataStreamFieldsFromDocumentDottedNotation () throws Exception {
96
+ IngestDocument ingestDocument = createIngestDocument ("logs-generic-default" );
97
+ ingestDocument .getCtxMap ().put ("data_stream.type" , "logs" );
98
+ ingestDocument .getCtxMap ().put ("data_stream.dataset" , "foo" );
99
+ ingestDocument .getCtxMap ().put ("data_stream.namespace" , "bar" );
100
+
101
+ RerouteProcessor processor = createRerouteProcessor (List .of (), List .of ());
102
+ processor .execute (ingestDocument );
103
+ assertDataSetFields (ingestDocument , "logs" , "foo" , "bar" );
104
+ }
105
+
84
106
public void testInvalidDataStreamFieldsFromDocument () throws Exception {
85
107
IngestDocument ingestDocument = createIngestDocument ("logs-generic-default" );
86
108
ingestDocument .setFieldValue ("data_stream.dataset" , "foo-bar" );
@@ -250,9 +272,15 @@ private RerouteProcessor createRerouteProcessor(String destination) {
250
272
}
251
273
252
274
private void assertDataSetFields (IngestDocument ingestDocument , String type , String dataset , String namespace ) {
253
- assertThat (ingestDocument .getFieldValue ("data_stream.type" , String .class ), equalTo (type ));
254
- assertThat (ingestDocument .getFieldValue ("data_stream.dataset" , String .class ), equalTo (dataset ));
255
- assertThat (ingestDocument .getFieldValue ("data_stream.namespace" , String .class ), equalTo (namespace ));
275
+ if (ingestDocument .hasField ("data_stream" )) {
276
+ assertThat (ingestDocument .getFieldValue ("data_stream.type" , String .class ), equalTo (type ));
277
+ assertThat (ingestDocument .getFieldValue ("data_stream.dataset" , String .class ), equalTo (dataset ));
278
+ assertThat (ingestDocument .getFieldValue ("data_stream.namespace" , String .class ), equalTo (namespace ));
279
+ } else {
280
+ assertThat (ingestDocument .getCtxMap ().get ("data_stream.type" ), equalTo (type ));
281
+ assertThat (ingestDocument .getCtxMap ().get ("data_stream.dataset" ), equalTo (dataset ));
282
+ assertThat (ingestDocument .getCtxMap ().get ("data_stream.namespace" ), equalTo (namespace ));
283
+ }
256
284
assertThat (ingestDocument .getFieldValue ("_index" , String .class ), equalTo (type + "-" + dataset + "-" + namespace ));
257
285
if (ingestDocument .hasField ("event.dataset" )) {
258
286
assertThat (
0 commit comments