Is this a bug of Elasticsearch sorting?

Problem Description: A field of keyword type causes a shard retrieval failure with differernt size and from value.

Environment:Node-4, Shard-8, Version-8.0

This is my query DSL on Kibana:

POST myIndex/_search
{
  "from": 10,
  "size": 4,
  "timeout": "1m",
  "query": {...},
  "sort": [
    {
      "warn_level": {
        "order": "desc"
      }
    },
    {
      "_score": {
        "order": "desc"
      }
    }
  ]
}

The sort field 'warn_level' is a field of keyword type, it only has four values ["1", "2", "3", "4"]. And the response result shows:

{
  "took" : 281,
  "timed_out" : false,
  "_shards" : {
    "total" : 2,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 1,
    "failures" : [
      {
        "shard" : 5,
        "index" : "myIndex",
        "node" : "Q3XOTW7gReK2hFI3xVu0bQ",
        "reason" : {
          "type" : "array_index_out_of_bounds_exception",
          "reason" : "Index -1 out of bounds for length 1"
        }
      }
    ]
  },
  "hits" : {
    "total" : {
      "value" : 0,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  }
}

But sometimes this query DSL is works and no error occurs.
Then I tried to use other keyword type fields to sort, and the same error occurred.

I just want to know what is causing this problem, thanks very much.

Welcome to our community! :smiley:

Can you share the mapping for your index?

For confidentiality, this is part of index mapping, and i use the 'warn_level' field to sort:

{
  "myIndex" : {
    "mappings" : {
      "dynamic" : "true",
      "properties" : {
        "a_audio_feature_vector_id" : {
          "type" : "keyword"
        },
        "a_audio_lang" : {
          "type" : "text"
        },
        "a_audio_trans_content" : {
          "type" : "text"
        },
        "a_logo" : {
          "type" : "text"
        },
        "a_ocr_position" : {
          "type" : "keyword"
        },
        "warn_level" : {
          "type" : "keyword"
        }
      }
    }
  }
}

My index mapping is blow your post

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.