Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

elasticsearch: set _type=doc #3757

Merged
merged 2 commits into from
Mar 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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