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

Mapping types deprecated in Elastic v8 #33

Open
joshuasprow opened this issue Jul 9, 2020 · 2 comments
Open

Mapping types deprecated in Elastic v8 #33

joshuasprow opened this issue Jul 9, 2020 · 2 comments

Comments

@joshuasprow
Copy link

Version Info:
go 1.14.4 darwin/amd64

github.com/olivere/elastic/v7 v7.0.17
github.com/sirupsen/logrus v1.6.0
gopkg.in/sohlich/elogrus.v7 v7.0.0

After initializing a new client with elastic.SetInfoLog() writing to stdout, I got a warning:

Deprecation warning: 299 Elasticsearch-7.8.0-757314695644ea9a1dc2fecd26d1a43856725e65 "[types removal] Specifying types in document index requests is deprecated, use the typeless endpoints instead (/{index}/_doc/{id}, /{index}/_doc, or /{index}/_create/{id})."

Here's the announcement from Elastic and a related issue: olivere/elastic#1295

It's not a currently breaking things, but it's always nice to get ahead of these things, right?

My first thought was to just delete .Type("log") here:

elogrus/hook.go

Lines 215 to 222 in 7aa9ea8

return func(entry *logrus.Entry, hook *ElasticHook) error {
r := elastic.NewBulkIndexRequest().
Index(hook.index()).
Type("log").
Doc(*createMessage(entry, hook))
processor.Add(r)
return nil
}, err

I'm not sure how to prevent a breaking change, though. If someone is relying on the "log" type, could they just append the type to their index? Ex: {index}/{type}.

@dobbbb
Copy link

dobbbb commented May 28, 2021

When you use bulk api and version of es is 7+, type needs to be '_doc'.

@dobbbb
Copy link

dobbbb commented May 28, 2021

r := elastic.NewBulkIndexRequest().Index(hook.index()).Type("log").Doc(*createMessage(entry, hook))
modify to
r := elastic.NewBulkIndexRequest().Index(hook.index()).Type("_doc").Doc(*createMessage(entry, hook))
or
r := elastic.NewBulkIndexRequest().Index(hook.index()).Doc(*createMessage(entry, hook))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants