Mapping types deprecated in Elastic v8
Opened this issue · 2 comments
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:
Lines 215 to 222 in 7aa9ea8
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}
.
When you use bulk api and version of es is 7+, type needs to be '_doc'.
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))