Skip to content
Oliver Eilhard edited this page May 6, 2017 · 7 revisions

Errors are returned with the standard Go mechanism. However, if you need to get the details of the error as reported by Elasticsearch, you can do so by "casting" to *elastic.Error. Here's an example:

_, err := client.IndexExists("twitter").Do()
if err != nil {
    // Get *elastic.Error which contains additional information
    e, ok := err.(*elastic.Error)
    if !ok {
        // This shouldn't happen
        ...
    }
    log.Printf("Elastic failed with status %d and error %s.", e.Status, e.Details)
    ...
}

See also: Connection errors.

Clone this wiki locally