Skip to content

Commit

Permalink
Ensure that match_only_text and wildcard fields can be added to defau…
Browse files Browse the repository at this point in the history
…lt_field list (#29634)

Fixes the construction of the index template's default_field list so that fields of type match_only_text
and wildcard can be added to it.
  • Loading branch information
adriansr authored Dec 30, 2021
1 parent 1386a04 commit 84924e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Affecting all Beats*

- Fields of type `match_only_text` (i.e. `message`) and `wildcard` were missing from the template's default_field list. {issue}29633[29633] {pull}29634[29634]

*Auditbeat*


Expand Down
2 changes: 1 addition & 1 deletion libbeat/template/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (p *Processor) Process(fields mapping.Fields, state *fieldState, output, an

if *field.DefaultField {
switch field.Type {
case "", "keyword", "text":
case "", "keyword", "text", "match_only_text", "wildcard":
addToDefaultFields(&field)
}
}
Expand Down
14 changes: 14 additions & 0 deletions libbeat/template/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,18 @@ func TestProcessDefaultField(t *testing.T) {
},
},
},
// Ensure that text_only_keyword fields can be added to default_field
mapping.Field{
Name: "a_match_only_text_field",
Type: "match_only_text",
DefaultField: &enableDefaultField,
},
// Ensure that wildcard fields can be added to default_field
mapping.Field{
Name: "a_wildcard_field",
Type: "wildcard",
DefaultField: &enableDefaultField,
},
}

version, err := common.NewVersion("7.0.0")
Expand All @@ -734,6 +746,8 @@ func TestProcessDefaultField(t *testing.T) {
}

expectedFields := []string{
"a_match_only_text_field",
"a_wildcard_field",
"bar",
"nested.bar",
"nested.foo",
Expand Down

0 comments on commit 84924e9

Please sign in to comment.