Skip to content

Commit

Permalink
elasticsearch: set _type=doc (#3757) (#4191)
Browse files Browse the repository at this point in the history
The `_type` field is deprecated per
elastic/elasticsearch#15613
(cherry picked from commit bec7603)
  • Loading branch information
tsg authored and monicasarbu committed May 3, 2017
1 parent 243d3af commit dc1a1e5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ https://github.com/elastic/beats/compare/v5.3.0...master[Check the HEAD diff]

*Affecting all Beats*

- Usage of field `_type` is now ignored and hardcoded to `doc`. {pull}3757[3757]

*Filebeat*

Expand Down
14 changes: 9 additions & 5 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ var (
errExcpectedObjectEnd = errors.New("expected end of object")
)

const (
eventType = "doc"
)

// NewClient instantiates a new client.
func NewClient(
s ClientSettings,
onConnectCallback connectCallback,
Expand Down Expand Up @@ -320,7 +325,7 @@ func createEventBulkMeta(
return bulkMeta{
Index: bulkMetaIndex{
Index: getIndex(event, index),
DocType: event["type"].(string),
DocType: eventType,
},
}
}
Expand All @@ -338,7 +343,7 @@ func createEventBulkMeta(
Index: bulkMetaIndex{
Index: getIndex(event, index),
Pipeline: pipeline,
DocType: event["type"].(string),
DocType: eventType,
},
}
}
Expand Down Expand Up @@ -535,7 +540,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 @@ -549,9 +553,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 dc1a1e5

Please sign in to comment.