Compare between Date Fields

I am trying to do this get this query
The Current date is after Current Milestone date it will then give all the documents in the index.

Here is my current query

GET /my_index/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "script": {
            "script": "doc['Current_Date'].date.isAfter(doc['Current Milestone'].date)"
          }
        }
      ]
    }
  }
}

But I got this error

{
  "error" : {
    "root_cause" : [
      {
        "type" : "script_exception",
        "reason" : "runtime error",
        "script_stack" : [
          "doc['Current_Date'].date.isAfter(doc['Current Milestone'].date)",
          "                   ^---- HERE"
        ],
        "script" : "doc['Current_Date'].date.isAfter(doc['Current Milestone'].date)",
        "lang" : "painless"
      }
    ],
    "type" : "search_phase_execution_exception",
    "reason" : "all shards failed",
    "phase" : "query",
    "grouped" : true,
    "failed_shards" : [
      {
        "shard" : 0,
        "index" : "my_index",
        "node" : "oTVgTN95Rn2CCce9gbz03g",
        "reason" : {
          "type" : "script_exception",
          "reason" : "runtime error",
          "script_stack" : [
            "doc['Current_Date'].date.isAfter(doc['Current Milestone'].date)",
            "                   ^---- HERE"
          ],
          "script" : "doc['Current_Date'].date.isAfter(doc['Current Milestone'].date)",
          "lang" : "painless",
          "caused_by" : {
            "type" : "illegal_argument_exception",
            "reason" : "Illegal list shortcut value [date]."
          }
        }
      }
    ]
  },
  "status" : 400
}

Anyone care to help? I have tried .value still fails

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