diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index a0f22f37698..5939fb5b887 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -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] diff --git a/libbeat/outputs/elasticsearch/client.go b/libbeat/outputs/elasticsearch/client.go index 3ac4b1da260..0a30c55c287 100644 --- a/libbeat/outputs/elasticsearch/client.go +++ b/libbeat/outputs/elasticsearch/client.go @@ -96,6 +96,10 @@ var ( errExcpectedObjectEnd = errors.New("expected end of object") ) +const ( + eventType = "doc" +) + // NewClient instantiates a new client. func NewClient( s ClientSettings, @@ -328,7 +332,7 @@ func createEventBulkMeta( return bulkMeta{ Index: bulkMetaIndex{ Index: getIndex(event, index), - DocType: event["type"].(string), + DocType: eventType, }, } } @@ -346,7 +350,7 @@ func createEventBulkMeta( Index: bulkMetaIndex{ Index: getIndex(event, index), Pipeline: pipeline, - DocType: event["type"].(string), + DocType: eventType, }, } } @@ -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) @@ -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