'Elasticsearch java.lang.Float cannot be cast to java.lang.Double exception

i get the above error when querying for items:

{
   "error": {
      "root_cause": [],
      "type": "reduce_search_phase_exception",
      "reason": "[reduce] ",
      "phase": "query",
      "grouped": true,
      "failed_shards": [],
      "caused_by": {
         "type": "class_cast_exception",
         "reason": "java.lang.Float cannot be cast to java.lang.Double"
      }
   },
   "status": 503
}

my query is:

GET items/item/_search/
{
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": ....
        }
      }
    }
  },
  "sort": [{"order": {"order": "desc", "missing": "_last"}}, {"popularity": {"order": "desc", "missing": "_last"}}],
  "size": 1000,
  "from": 0
}

i have a clue that this is because of the 'popularity' field in the 'sort', when removing it the error does not raise.

my mapping is:

"popularity": {
    "type": "double"
  },

my question actually is how to fix the invalid document that raising this issue? how can I find it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source