mattbaird / elastigo

A Go (golang) based Elasticsearch client library.
Apache License 2.0
943 stars 241 forks source link

requests are sent without content-type header #297

Open ththvseo opened 6 years ago

ththvseo commented 6 years ago

since ES 5.3, every request without content-type header triggers a warning.

Content type detection for rest requests is deprecated. Specify the content type using the [Content-Type] header.

just look at the competition's ticket here: https://github.com/olivere/elastic/issues/511

there is currently no interface available to set the content-type (or other headers), and no code that sets it. (with one exception in SetBodyJson(): https://github.com/mattbaird/elastigo/blob/master/lib/request.go#L80 )

(a sub-issue is that the header is not set in SetBodyGzip() even when serializing json: https://github.com/mattbaird/elastigo/issues/295 )

an expectation with a go library would be that it should be possible to inject a custom http.Client compatible client, which would allow overriding headers.

inmylo commented 6 years ago

With Elasticsearch 6.x elastigo searches don't work at all ! Error: Error [Content-Type header [] is not supported] Status [406] [406].

Please add a header or make it configurable.

lindhor commented 6 years ago

In Elasticsearch 6.x Content-Type header is required. https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests

inmylo commented 6 years ago

Don't bother, this project looks dead long time ago - check commits and closed issues history. Move to https://github.com/olivere/elastic, or wait for official client