Skip to content

Commit

Permalink
elasticsearch: set _type=doc (#3757)
Browse files Browse the repository at this point in the history
The `_type` field is deprecated per
elastic/elasticsearch#15613
  • Loading branch information
7AC authored Mar 17, 2017
1 parent 641323a commit bec7603
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ https://github.com/elastic/beats/compare/v5.1.1...master[Check the HEAD diff]
- Change beat generator. Use `$GOPATH/src/github.com/elastic/beats/script/generate.py` to generate a beat. {pull}3452[3452]
- Configuration files must be owned by the user running the beat or by root, and
they must not be writable by others. {pull}3544[3544] {pull}3689[3689]
- Usage of field `_type` is now ignored and hardcoded to `doc`. {pull}3757[3757]

*Filebeat*
- Always use absolute path for event and registry. This can lead to issues when relative paths were used before. {pull}3328[3328]
Expand Down
13 changes: 8 additions & 5 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ var (
errExcpectedObjectEnd = errors.New("expected end of object")
)

const (
eventType = "doc"
)

// NewClient instantiates a new client.
func NewClient(
s ClientSettings,
Expand Down Expand Up @@ -328,7 +332,7 @@ func createEventBulkMeta(
return bulkMeta{
Index: bulkMetaIndex{
Index: getIndex(event, index),
DocType: event["type"].(string),
DocType: eventType,
},
}
}
Expand All @@ -346,7 +350,7 @@ func createEventBulkMeta(
Index: bulkMetaIndex{
Index: getIndex(event, index),
Pipeline: pipeline,
DocType: event["type"].(string),
DocType: eventType,
},
}
}
Expand Down Expand Up @@ -548,7 +552,6 @@ func (client *Client) PublishEvent(data outputs.Data) error {

event := data.Event
index := getIndex(event, client.index)
typ := event["type"].(string)

debugf("Publish event: %s", event)

Expand All @@ -562,9 +565,9 @@ func (client *Client) PublishEvent(data outputs.Data) error {

var status int
if pipeline == "" {
status, _, err = client.Index(index, typ, "", client.params, event)
status, _, err = client.Index(index, eventType, "", client.params, event)
} else {
status, _, err = client.Ingest(index, typ, pipeline, "", client.params, event)
status, _, err = client.Ingest(index, eventType, pipeline, "", client.params, event)
}

// check indexing error
Expand Down

0 comments on commit bec7603

Please sign in to comment.