go-elasticsearch
go-elasticsearch copied to clipboard
Do we support CBOR format communicating
hi guys,
I just noticed https://github.com/elastic/go-elasticsearch/blob/v6.8.5/esapi/api.search.go#L316, seems all the data format we could support is json.
and from the official document https://www.elastic.co/guide/en/elasticsearch/reference/6.8/common-options.html#_content_type_requirements. I got a little confused, will we support the data format other than json in this library.
Hello, I don't think any of the official libraries support CBOR.
There's no built-support for CBOR in go-elasticsearch, but since the body is passed as an io.Reader
, you can play with it, and setting the request header to a corresponding value — but again, I've never tried.
If you're after faster JSON encoding, have a look into examples in https://github.com/elastic/go-elasticsearch/tree/master/_examples/encoding.
hi @karmi , I've tried with original non-modified this library. it doesn't work, since we just combined all the values of a same-key-header.
I'm considering a PR to fix it, and based on two reasons,
- it even will fail if I set the
Content-Type
toapplication/json
manually. - to let this library to be compatible with official document.
Agreed, I think these lines should be wrapped in a condition like req.Header[headerContentType] == ""
:
https://github.com/elastic/go-elasticsearch/blob/aff00e5adfde9994ddeb2619ecb7b2131071c338/esapi/api.search.go#L315-L317
What if you play with it eg. with the Search (etc) API, and I can later update the generator.