Elasticsearch 3 of 280 shards failed error - 有没有人以前见过这样的事情并且知道如何修复它?

Elasticsearch 3 of 280 shards failed error - has anyone seen anything like this before and knows how to fix it?

Every time I load the dashboard based on this index, this error keeps popping up

我的可视化看起来仍然很好,数据仍然出现,我以前从未遇到过这个错误。关于如何解决此问题的任何想法?

这是错误弹出窗口的响应:

{
  "took": 1137,
  "timed_out": false,
  "terminated_early": false,
  "_shards": {
    "total": 280,
    "successful": 277,
    "skipped": 0,
    "failed": 3,
    "failures": [
      {
        "shard": 1,
        "index": "nbs_comprehend-2021-w41",
        "node": "oGEHA-aRSnmwuEmqSZc6Kw",
        "reason": {
          "type": "script_exception",
          "reason": "runtime error",
          "script_stack": [
            "org.elasticsearch.index.fielddata.ScriptDocValues$Longs.get(ScriptDocValues.java:121)",
            "org.elasticsearch.index.fielddata.ScriptDocValues$Longs.getValue(ScriptDocValues.java:115)",
            "doc['user.followers_count'].value > 9999 ? 1 : 0",
            "                           ^---- HERE"
          ],
          "script": "doc['user.followers_count'].value > 9999 ? 1 : 0",
          "lang": "painless",
          "position": {
            "offset": 27,
            "start": 0,
            "end": 48
          },
          "caused_by": {
            "type": "illegal_state_exception",
            "reason": "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"
          }
        }
      }
    ]
  },
  "hits": {
    "total": 696059,
    "max_score": null,
    "hits": []
  },
  "aggregations": {
    "termsAgg": {
      "doc_count_error_upper_bound": 0,
      "sum_other_doc_count": 0,
      "buckets": [
        {
          "key": 0,
          "doc_count": 604397
        },
        {
          "key": 1,
          "doc_count": 91662
        }
      ]
    }
  }
}

您的文档中有一个字段没有 user.followers_count 的值。您的脚本字段根本不检查它,因此当它不能 return 任何值时会出错。这就是 A document doesn't have a value for a field 在错误

中所说的

试试这个,如果字段为空,这将 return 一个零,基本上创建一个默认值;

if (doc['user.followers_count'].size() == 0) { return "0" } else { return doc['user.followers_count'].value > 9999 ? 1 : 0 }