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 22, 2015
·
2 revisions
Elastic enables you to use your own decoder for deserializing JSON data as received from Elasticsearch. Use client.SetDecoder(...) to implement your own.
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.SetDecoder(&CountingDecoder{})