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

Always _doc if Beats major version is 7 and ES >= 6 #9573

Merged
merged 1 commit into from
Dec 17, 2018
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
11 changes: 2 additions & 9 deletions libbeat/outputs/elasticsearch/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ var (
)

const (
defaultEventTypeES6 = "doc"
defaultEventTypeES7 = "_doc"
defaultEventType = defaultEventTypeES7
defaultEventType = "_doc"
)

// NewClient instantiates a new client.
Expand Down Expand Up @@ -691,12 +689,7 @@ func (client *Client) Connect() error {
return err
}

if client.GetVersion().Major < 7 {
client.eventType = defaultEventTypeES6
} else {
client.eventType = defaultEventType
}

client.eventType = defaultEventType
return nil
}

Expand Down
7 changes: 1 addition & 6 deletions libbeat/outputs/elasticsearch/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,12 +395,7 @@ func TestBulkEncodeEvents(t *testing.T) {
config common.MapStr
events []common.MapStr
}{
"ES 6.x event": {
docType: "doc",
config: common.MapStr{},
events: []common.MapStr{{"message": "test"}},
},
"ES 7.x event": {
"Beats 7.x event": {
docType: "_doc",
config: common.MapStr{},
events: []common.MapStr{{"message": "test"}},
Expand Down
10 changes: 2 additions & 8 deletions libbeat/template/load_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ func TestTemplateWithData(t *testing.T) {
assert.True(t, loader.CheckTemplate(tmpl.GetName()))

for _, test := range dataTests {
_, _, err = client.Index(tmpl.GetName(), "doc", "", nil, test.data)
_, _, err = client.Index(tmpl.GetName(), "_doc", "", nil, test.data)
if test.error {
assert.NotNil(t, err)

Expand Down Expand Up @@ -395,13 +395,7 @@ func getTemplate(t *testing.T, client ESClient, templateName string) testTemplat
}

func (tt *testTemplate) SourceEnabled() bool {
docType := "_doc"
major := tt.client.GetVersion().Major
if major < 7 {
docType = "doc"
}

key := fmt.Sprintf("mappings.%v._source.enabled", docType)
key := fmt.Sprintf("mappings._doc._source.enabled")

// _source.enabled is true if it's missing (default)
b, _ := tt.HasKey(key)
Expand Down
5 changes: 1 addition & 4 deletions libbeat/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,12 @@ func (t *Template) Generate(properties common.MapStr, dynamicTemplates []common.
indexSettings.Put("number_of_routing_shards", defaultNumberOfRoutingShards)
}

var mappingName string
mappingName := "_doc"
major := t.esVersion.Major
switch {
case major < 6:
mappingName = "_default_"
case major == 6:
mappingName = "doc"
case major >= 7:
mappingName = "_doc"
defaultFields = append(defaultFields, "fields.*")
indexSettings.Put("query.default_field", defaultFields)
}
Expand Down