-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Aggregations returned as base64 encoded string (json.RawMessage) #51
Comments
Thanks for reporting this. You learn a new thing every day. :-) |
Can you test if the issue-51 branch solves the issue for you? If you can, it would be very helpful if you can provide a test for it... |
FYI: Marshaling results back into JSON is not tested in Elastic. There might be issues with fields not being attributed with |
Thank you so much for this, I was experiencing the same issue today! |
@sevein My pleasure. May I ask what's your use case for serializing the results back into JSON? |
Thanks! @olivere, sorry was really caught up the last couple weeks... couldn't help |
if you json.Marshal(result) on query result with aggregations, the aggregation results are marshaled as a base64 encoded string , whereas the query hits are not, which is a bit of a hassle. You can test it by marshaling the result from a query execution that uses aggregation. I tested with TermsAggregation.
You can solve it by using result.Aggregations... but not for entire result response.
type Aggregations map[string]json.RawMessage
Its because json.RawMessage is not a pointer (reference: https://groups.google.com/forum/#!topic/Golang-Nuts/38ShOlhxAYY).
Changing it to
type Aggregations map[string]*json.RawMessage
along with its usage insearch_aggs.go
solves it :) But I am not sure about other ramifications due to this.If you like this, I can submit a pull request. For now, I have just forked the repo.
Thanks.
The text was updated successfully, but these errors were encountered: