Deprecation message: getDate is no longer necessary on date fields

I am receiving the deprecation message "getDate is no longer necessary on date fields" on the following:

POST _scripts/test-date
{
  "script": {
    "lang": "painless",
    "source": "doc['starttime'].date.hourOfDay < params.startHour"
  }
}

GET daterangetest/_search
{
  "query": {
    "script": {
      "script": {
        "id": "test-date",
        "params": {
          "startHour": 10
        }
      }
    }
  }
}

However, if I attempt to use any format other than doc['starttime'].date.hourOfDay I receive errors. Is there a better way I should be doing this?

As a follow up: I've been having some difficulty finding examples and documentation of using dates and date_ranges in Painless scripts. Can anyone suggest some reading?

Oof, classic rubber duck debugging - I worked out I should be using .value. instead of .date.

POST _scripts/test-date
{
  "script": {
    "lang": "painless",
    "source": "doc['starttime'].value.hourOfDay < params.startHour"
  }
}

That said, my original request stands: can you recommend some examples of date and/or date_range manipulation in Painless?

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