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

Do we support CBOR format communicating #132

Closed
junchih opened this issue Feb 11, 2020 · 3 comments · Fixed by #536
Closed

Do we support CBOR format communicating #132

junchih opened this issue Feb 11, 2020 · 3 comments · Fixed by #536

Comments

@junchih
Copy link

junchih commented Feb 11, 2020

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.

@karmi
Copy link
Contributor

karmi commented Feb 11, 2020

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.

@junchih
Copy link
Author

junchih commented Feb 12, 2020

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,

  1. it even will fail if I set the Content-Type to application/json manually.
  2. to let this library to be compatible with official document.

@karmi
Copy link
Contributor

karmi commented Feb 12, 2020

Agreed, I think these lines should be wrapped in a condition like req.Header[headerContentType] == "":

if r.Body != nil {
req.Header[headerContentType] = headerContentTypeJSON
}

What if you play with it eg. with the Search (etc) API, and I can later update the generator.

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

Successfully merging a pull request may close this issue.

2 participants