elastic / elasticsearch

Free and Open, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
69.44k stars 24.57k forks source link

async search returns is_partial:false when local cluster has shard errors #98725

Open nreese opened 1 year ago

nreese commented 1 year ago

Elasticsearch Version

main

Installed Plugins

none

Java Version

bundled

OS Version

21.6.0 Darwin Kernel Version 21.6.0

Problem Description

async search returns is_partial:false when local cluster has shard errors

Steps to Reproduce

PUT local1
{}

PUT local1/_mapping
{
  "properties": {
    "value": {
      "type": "keyword"
    }
  }
}

PUT local1/_doc/1
{
    "value" : "foo1"
}

PUT local2
{}

PUT local2/_mapping
{
  "properties": {
    "value": {
      "type": "keyword"
    }
  }
}

PUT local2/_doc/1
{
    "value" : "foo2"
}

POST /local*/_async_search
{
  "query": {
    "error_query": {
      "indices": [
        {
          "error_type": "exception",
          "message": "local shard failure message 123",
          "name": "local2"
        }
      ]
    }
  }
}

In the response, notice how is_partial is false. However, results are partial because local2 shard failed to return results and only a single hit is returned. Complete results should include 2 hits

{
  "is_partial": false,
  "is_running": false,
  "start_time_in_millis": 1692708012844,
  "expiration_time_in_millis": 1693140012844,
  "completion_time_in_millis": 1692708012845,
  "response": {
    "took": 1,
    "timed_out": false,
    "_shards": {
      "total": 2,
      "successful": 1,
      "skipped": 0,
      "failed": 1,
      "failures": [
        {
          "shard": 0,
          "index": "local2",
          "node": "XPQtz28bSLW26Oynf6oUmg",
          "reason": {
            "type": "query_shard_exception",
            "reason": "failed to create query: [local2][0] local shard failure message 123",
            "index_uuid": "-MsFEeVHRU6e20nK5cRwXw",
            "index": "local2",
            "caused_by": {
              "type": "runtime_exception",
              "reason": "[local2][0] local shard failure message 123"
            }
          }
        }
      ]
    },
    "hits": {
      "total": {
        "value": 1,
        "relation": "eq"
      },
      "max_score": 1,
      "hits": [
        {
          "_index": "local1",
          "_id": "1",
          "_score": 1,
          "_source": {
            "value": "foo1"
          }
        }
      ]
    }
  }
}

Logs (if relevant)

No response

elasticsearchmachine commented 1 year ago

Pinging @elastic/es-search (Team:Search)

elasticsearchmachine commented 1 month ago

Pinging @elastic/es-search-foundations (Team:Search Foundations)