sirensolutions / siren-join

[This is the old, single node version for Elasticsearch 2.x, see the latest "Siren Federate" plugin for distributed Elasticsearch 5.x and 6.x capabilities]
http://siren.io
GNU Affero General Public License v3.0
183 stars 60 forks source link

error reporting #92

Open scampi opened 8 years ago

scampi commented 8 years ago

The coordinate_msearch action does not return the error properly.

For example, if you send the following request that has a wrong query:

{"index":["company"],"ignore_unavailable":true}
{"query":{"filtered":{"query":{"query_string":{"analyze_wildcard":true,"query":"xxx(yyy"}}}}}

The _msearch action returns the following object:

{
  "responses": [
    {
      "error": {
        "root_cause": [
          {
            "type": "query_parsing_exception",
            "reason": "Failed to parse query [xxx(yyy]",
            "index": "company",
            "line": 1,
            "col": 89
          }
        ],
        "type": "search_phase_execution_exception",
        "reason": "all shards failed",
        "phase": "query",
        "grouped": true,
        "failed_shards": [
          {
            "shard": 0,
            "index": "company",
            "node": "SfoK4MmMQdywBrGYNAiMxQ",
            "reason": {
              "type": "query_parsing_exception",
              "reason": "Failed to parse query [xxx(yyy]",
              "index": "company",
              "line": 1,
              "col": 89,
              "caused_by": {
                "type": "parse_exception",
                "reason": "Cannot parse 'xxx(yyy': Encountered \"<EOF>\" at line 1, column 7.\nWas expecting one of:\n    <AND> ...\n    <OR> ...\n    <NOT> ...\n    \"+\" ...\n    \"-\" ...\n    <BAREOPER> ...\n    \"(\" ...\n    \")\" ...\n    \"*\" ...\n    \"^\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <FUZZY_SLOP> ...\n    <PREFIXTERM> ...\n    <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\" ...\n    <NUMBER> ...\n    ",
                "caused_by": {
                  "type": "parse_exception",
                  "reason": "Encountered \"<EOF>\" at line 1, column 7.\nWas expecting one of:\n    <AND> ...\n    <OR> ...\n    <NOT> ...\n    \"+\" ...\n    \"-\" ...\n    <BAREOPER> ...\n    \"(\" ...\n    \")\" ...\n    \"*\" ...\n    \"^\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <FUZZY_SLOP> ...\n    <PREFIXTERM> ...\n    <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\" ...\n    <NUMBER> ...\n    "
                }
              }
            }
          }
        ]
      }
    }
  ]
}

However, the action _coordinate_msearch returns the error as a string only. This is a problem because kibi/kibana relies on some of the fields that are ommited below for error reporting.

{
  "responses": [
    {
      "error": "SearchPhaseExecutionException[all shards failed]; nested: QueryParsingException[Failed to parse query [xxx(yyy]]; nested: ParseException[Cannot parse 'xxx(yyy': Encountered \"<EOF>\" at line 1, column 7.\nWas expecting one of:\n    <AND> ...\n    <OR> ...\n    <NOT> ...\n    \"+\" ...\n    \"-\" ...\n    <BAREOPER> ...\n    \"(\" ...\n    \")\" ...\n    \"*\" ...\n    \"^\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <FUZZY_SLOP> ...\n    <PREFIXTERM> ...\n    <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\" ...\n    <NUMBER> ...\n    ]; nested: ParseException[Encountered \"<EOF>\" at line 1, column 7.\nWas expecting one of:\n    <AND> ...\n    <OR> ...\n    <NOT> ...\n    \"+\" ...\n    \"-\" ...\n    <BAREOPER> ...\n    \"(\" ...\n    \")\" ...\n    \"*\" ...\n    \"^\" ...\n    <QUOTED> ...\n    <TERM> ...\n    <FUZZY_SLOP> ...\n    <PREFIXTERM> ...\n    <WILDTERM> ...\n    <REGEXPTERM> ...\n    \"[\" ...\n    \"{\" ...\n    <NUMBER> ...\n    ]; "
    }
  ]
}