Skip to content

Unmarshal error of parsing shards failures in SearchResult #291

Description

@nodestory

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).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions