Script field

Good morning,

I'm beginning to work with scripting fields and I have doubts and problems. I have created this index:

POST /sergi-script/_doc/1
  "access": "2023-10-26T00:00:00"

POST /sergi-script/_doc/2
  "access": "2023-10-26T00:00:00",
  "photo": true

And now my intention is create an script fields using this info:

  1. Get a boolean when the access field is befoire than a date:
GET /sergi-script/_search
  "query": {
    "match_all": {}
  "script_fields": {
    "antes": {
      "script": {
        "lang": "painless", 
        "source": "doc['access'].value.isBefore(params['date1'])",
        "params": {
          "date1": "2023-01-01T00:00:00"

I have an error but I don't understand the reason :frowning:

  1. Is it possible get a boolean field that returns true (when the field photo exists) otherwise false?

Thanks for the help

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