You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Oliver Eilhard edited this page Feb 26, 2015
·
2 revisions
Elastic enables you to use your own decoder for deserializing JSON data as received from Elasticsearch. Set your own decoder when creating a new client via elastic.SetDecoder(...).
Here is an example:
// CountingDecoder needs to implement the elastic.Decoder interface.typeCountingDecoderstruct {
dec json.DecoderNint64
}
func (d*CountingDecoder) Decode(data []byte, vinterface{}) error {
atomic.AddInt64(&d.N, 1)
returnjson.NewDecoder(bytes.NewReader(data)).Decode(v)
}
...client, err:=elastic.NewClient(elastic.SetDecoder(&CountingDecoder{}))