Skip to content
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
Verify default logs-*-* settings and mappings:
- do:
indices.create_data_stream:
name: logs-test-1
- is_true: acknowledged

- do:
indices.get_data_stream:
name: logs-test-1
- set: { data_streams.0.indices.0.index_name: idx0name }

# default backing index settings should be "ignore_malformed": true
- do:
indices.get_settings:
index: $idx0name
- match: { .$idx0name.settings.index.mapping.ignore_malformed: "true" }

# add test field mapping
- do:
indices.put_mapping:
index: $idx0name
body:
properties:
numeric_field:
type: integer
- is_true: acknowledged

# default backing index mapping should contain an exception for the @timestamp field - "ignore_malformed": false
- do:
indices.get_mapping:
index: $idx0name
- match: { [email protected]_malformed: false }
- match: { .$idx0name.mappings.properties.numeric_field.type: "integer" }

- do:
index:
index: logs-test-1
refresh: true
body:
'@timestamp': '2023-04-18'
message: 'valid'
numeric_field: 42
- match: {result: "created"}

- do:
index:
index: logs-test-1
refresh: true
body:
'@timestamp': '2023-04-18'
message: 'invalid_type_valid_value'
numeric_field: "42"
- match: {result: "created"}

- do:
index:
index: logs-test-1
refresh: true
body:
'@timestamp': '2023-04-18'
message: 'invalid_type_invalid_value'
numeric_field: "forty-two"
- match: {result: "created"}

- do:
search:
index: logs-test-1
body:
query:
match:
message:
query: 'valid'
fuzziness: '0'
fields:
- field: 'numeric_field'
- length: { hits.hits: 1 }
- length: { hits.hits.0.fields: 1 }
- match: { hits.hits.0.fields.numeric_field.0: 42 }

- do:
search:
index: logs-test-1
body:
query:
match:
message:
query: 'invalid_type_valid_value'
fuzziness: '0'
fields:
- field: 'numeric_field'
- length: { hits.hits: 1 }
- length: { hits.hits.0.fields: 1 }
- match: { hits.hits.0.fields.numeric_field.0: 42 }

- do:
search:
index: logs-test-1
body:
query:
match:
message:
query: 'invalid_type_invalid_value'
fuzziness: '0'
fields:
- field: 'numeric_field'
- length: { hits.hits: 1 }
- length: { hits.hits.0._ignored: 1 }
- match: { hits.hits.0._ignored.0: 'numeric_field' }
- length: { hits.hits.0.ignored_field_values.numeric_field: 1 }
- match: { hits.hits.0.ignored_field_values.numeric_field.0: 'forty-two' }
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"date_detection": false,
"properties": {
"@timestamp": {
"type": "date"
"type": "date",
"ignore_malformed": false
},
"data_stream": {
"properties": {
Expand Down
4 changes: 4 additions & 0 deletions x-pack/plugin/core/src/main/resources/logs-mappings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"template": {
"mappings": {
"properties": {
"@timestamp": {
"type": "date",
"ignore_malformed": false
},
"data_stream": {
"properties": {
"type": {
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugin/core/src/main/resources/logs-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"codec": "best_compression",
"query": {
"default_field": ["message"]
},
"mapping": {
"ignore_malformed": true
}
}
}
Expand Down