elastigo icon indicating copy to clipboard operation
elastigo copied to clipboard

Unmarshal error of parsing shards failures in SearchResult

Open nodestory opened this issue 8 years ago • 0 comments

The field ShardStatus of SearchResult contains the field Failure which is defined as follows:

type Failure struct {
    Index  string    `json:"index"`
    Shard  StatusInt `json:"shard"`
    Reason string    `json:"reason"`
}

But actually I got the failure in the response like this when scrolling the results:

{
    "shard": -1,
    "index": null,
    "reason": {
      "type": "es_rejected_execution_exception",
      "reason": "..."
    }
}

So every time if some shards fail, I'll get an error json: cannot unmarshal object into Go value of type string from here.

It seems that Reason should be a struct with two string fields type and reason, but I'm not sure if the response format depends on the version of Elasticsearch (currently I'm using 2.2.2).

nodestory avatar Jan 13 '17 06:01 nodestory