Skip to content

Commit

Permalink
Ignore non index fields in default_field for Elasticsearch (elastic#9549
Browse files Browse the repository at this point in the history
)

We recently started to use fields with `index: false`. By default all fields are defined as keyword internally which meant these fields were also added to the list of default_fields for Elasticsearch. With this PR these fields are now excluded.

(cherry picked from commit 77c34fc)
  • Loading branch information
ruflin committed Dec 14, 2018
1 parent 6f8366d commit 5ca240f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ https://github.com/elastic/beats/compare/v6.5.0...6.x[Check the HEAD diff]
- Log events at the debug level when dropped by encoding problems. {pull}9251[9251]
- Refresh host metadata in add_host_metadata. {pull}9359[9359]
- When collecting swap metrics for beats telemetry or system metricbeat module handle cases of free swap being bigger than total swap by assuming no swap is being used. {issue}6271[6271] {pull}9383[9383]
- Ignore non index fields in default_field for Elasticsearch. {pull}9549[9549]

*Auditbeat*

Expand Down
8 changes: 6 additions & 2 deletions libbeat/template/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ func (p *Processor) keyword(f *common.Field) common.MapStr {
fullName = f.Path + "." + f.Name
}

defaultFields = append(defaultFields, fullName)
if f.Index == nil || (f.Index != nil && *f.Index) {
defaultFields = append(defaultFields, fullName)
}

property["type"] = "keyword"

Expand Down Expand Up @@ -201,7 +203,9 @@ func (p *Processor) text(f *common.Field) common.MapStr {
fullName = f.Path + "." + f.Name
}

defaultFields = append(defaultFields, fullName)
if f.Index == nil || (f.Index != nil && *f.Index) {
defaultFields = append(defaultFields, fullName)
}

properties["type"] = "text"

Expand Down

0 comments on commit 5ca240f

Please sign in to comment.