# Date property is not recognised

**URL:** <https://discuss.elastic.co/t/date-property-is-not-recognised/220738>\
**Category:** Kibana\
**Created:** [February 24, 2020, 11:20pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738 "2020-02-24T23:20:27Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![KibanaUser2](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@KibanaUser2](https://discuss.elastic.co/u/KibanaUser2)\
**Post date:** [February 24, 2020, 11:20pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/1 "2020-02-24T23:20:27Z")

</div>

I am new to Kibana. I am facing a strange issue. I have an index which has date propety as well as timestamp. When I am trying to extract the date and month from the date property in scripted field , I am getting exception . But When I use time stamp I can see the data coming up in the index.

If I use the below one

def Daymonth =doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear ;

I get this error 🙂"type": "script\_exception",  
"reason": "runtime error",  
"script\_stack": [  
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.get(ScriptDocValues.java:160)",  
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.getValue(ScriptDocValues.java:154)",  
"Daymonth =doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear ;\n//def Daymonth = doc['timeStamp'].value.year.toString() + doc['timeStamp'].value.monthOfYear.toString() + doc['timeStamp'].value.dayOfMonth ;\n",  
" ^---- HERE"  
],  
"script": "\n\n//def path = doc['applicationData.transactionTimeStatistics.sessionStartTime'];\ndef Daymonth =doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear ;\n//def Daymonth = doc['timeStamp'].value.year.toString() + doc['timeStamp'].value.monthOfYear.toString() + doc['timeStamp'].value.dayOfMonth ;\nreturn Daymonth;\n//}\n//return "Hai"\n",  
"lang": "painless"  
}  
],  
"type": "search\_phase\_execution\_exception",  
"reason": "all shards failed",  
"phase": "query",  
"grouped": true,  
"failed\_shards": [  
{  
"shard": 0,  
"index": "report-kiosk-session-",  
"node": "zjRc5DLTROSI4UG211ktpg",  
"reason": {  
"type": "script\_exception",  
"reason": "runtime error",  
"script\_stack": [  
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.get(ScriptDocValues.java:160)",  
"org.elasticsearch.index.fielddata.ScriptDocValues$Dates.getValue(ScriptDocValues.java:154)",  
"Daymonth =doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear ;\n//def Daymonth = doc['timeStamp'].value.year.toString() + doc['timeStamp'].value.monthOfYear.toString() + doc['timeStamp'].value.dayOfMonth ;\n",  
" ^---- HERE"  
],  
"script": "\n\n//def path = doc['applicationData.transactionTimeStatistics.sessionStartTime'];\ndef Daymonth =doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear ;\n//def Daymonth = doc['timeStamp'].value.year.toString() + doc['timeStamp'].value.monthOfYear.toString() + doc['timeStamp'].value.dayOfMonth ;\nreturn Daymonth;\n//}\n//return "Hai"\n",  
"lang": "painless",  
"caused\_by": {  
"type": "illegal\_state\_exception",  
"reason": "A document doesn't have a value for a field! Use doc[].size()==0 to check if a document is missing a field!"

But If I use

def Daymonth = doc['timeStamp'].value.year.toString() + doc['timeStamp'].value.monthOfYear.toString() + doc['timeStamp'].value.dayOfMonth ;

I can see the data coming . I cant understand what is issue .

I checked the index . Both are date type properties

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [February 25, 2020, 12:31am UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/2 "2020-02-25T00:31:09Z")

</div>

Hi, can you show the mapping of your index, and include the entire script for this scripted field?

---

<div class="post-metadata">

**Author:** ![KibanaUser2](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@KibanaUser2](https://discuss.elastic.co/u/KibanaUser2)\
**Post date:** [March 4, 2020, 4:10am UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/3 "2020-03-04T04:10:15Z")

</div>

Hi sullivan

Below is the scripted field I was trying to create , which gives me error.

doc['applicationData.intiatingPassengerRawMrz.keyword'] + doc['applicationData.kioskPort.keyword'].toString() + doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.year.toString() + doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear.toString() + doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.dayOfMonth

---

<div class="post-metadata">

**Author:** ![KibanaUser2](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@KibanaUser2](https://discuss.elastic.co/u/KibanaUser2)\
**Post date:** [March 4, 2020, 4:51am UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/5 "2020-03-04T04:51:15Z")

</div>

Here is the index. I cant post the entire one as it is big to post here . I will just extract the mapping for the problematic area.

```
		transactionTimeStatistics" : {
          "properties" : {
            "airportDetailsTime" : {
              "type" : "float"
            },
            "amadeusDcsTime" : {
              "type" : "float"
            },
            "amadeusInternalTime" : {
              "type" : "float"
            },
            "amadeusTime" : {
              "type" : "float"
            },
            "csaAccessControlTime" : {
              "type" : "float"
            },
            "csaSessionEndTime" : {
              "type" : "date"
            },
            "csaSessionStartTime" : {
              "type" : "date"
            },
            "csaTotalTime" : {
              "type" : "float"
            },
            "frequentFlyerTime" : {
              "type" : "float"
            },
            "lastScreenDisplayed" : {
              "type" : "text",
              "fields" : {
                "keyword" : {
                  "type" : "keyword",
                  "ignore_above" : 256
                }
              }
            },
            "lastScreenStartTime" : {
              "type" : "date"
            },
            "machineTime" : {
              "type" : "float"
            },
            "nameMatcherTime" : {
              "type" : "float"
            },
            
            "paxTime" : {
              "type" : "float"
            },
            "sessionEndTime" : {
              "type" : "date"
            },
            "sessionStartTime" : {
              "type" : "date"
            },
            "subscriptionServiceTime" : {
              "type" : "float"
            },
            "totalTime" : {
              "type" : "float"
            }
          }
        }
```

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [March 9, 2020, 7:51pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/6 "2020-03-09T19:51:38Z")

</div>

Hi, can you try this script?

```auto
doc['applicationData.intiatingPassengerRawMrz.keyword'].value +
doc['applicationData.kioskPort.keyword'].value +
doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.year +
doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear +
doc['applicationData.transactionTimeStatistics.sessionStartTime'].value.dayOfMonth

```

---

<div class="post-metadata">

**Author:** ![KibanaUser2](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@KibanaUser2](https://discuss.elastic.co/u/KibanaUser2)\
**Post date:** [March 9, 2020, 10:17pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/7 "2020-03-09T22:17:49Z")

</div>

Hi Sullivan

I tried the the script given by you . I got same error.

```auto
{
 "root_cause": [
  {
   "type": "script_exception",
   "reason": "runtime error",
   "script_stack": [
    "org.elasticsearch.index.fielddata.ScriptDocValues$Strings.get(ScriptDocValues.java:496)",
    "org.elasticsearch.index.fielddata.ScriptDocValues$Strings.getValue(ScriptDocValues.java:503)",
    "doc['applicationData.intiatingPassengerRawMrz.keyword'].value +\n\ndoc['applicationData.kioskPort.keyword'].value +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.year +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.dayOfMonth\n",
    " ^---- HERE"
   ],
   "script": "doc['applicationData.intiatingPassengerRawMrz.keyword'].value +\n\ndoc['applicationData.kioskPort.keyword'].value +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.year +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.dayOfMonth\n",
   "lang": "painless"
  }
 ],
 "type": "search_phase_execution_exception",
 "reason": "all shards failed",
 "phase": "query",
 "grouped": true,
 "failed_shards": [
  {
   "shard": 0,
   "index": "report-kiosk-session-",
   "node": "zjRc5DLTROSI4UG211ktpg",
   "reason": {
    "type": "script_exception",
    "reason": "runtime error",
    "script_stack": [
     "org.elasticsearch.index.fielddata.ScriptDocValues$Strings.get(ScriptDocValues.java:496)",
     "org.elasticsearch.index.fielddata.ScriptDocValues$Strings.getValue(ScriptDocValues.java:503)",
     "doc['applicationData.intiatingPassengerRawMrz.keyword'].value +\n\ndoc['applicationData.kioskPort.keyword'].value +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.year +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.dayOfMonth\n",
     " ^---- HERE"
    ],
    "script": "doc['applicationData.intiatingPassengerRawMrz.keyword'].value +\n\ndoc['applicationData.kioskPort.keyword'].value +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.year +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.monthOfYear +\n\ndoc['applicationData.transactionTimeStatistics.sessionStartTime'].value.dayOfMonth\n",
    "lang": "painless",
    "caused_by": {
     "type": "illegal_state_exception",
     "reason": "A document doesn't have a value for a field! Use doc[<field>].size()==0 to check if a document is missing a field!"
    }
   }
  }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![tsullivan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tsullivan/32/31077_2.png) [@tsullivan](https://discuss.elastic.co/u/tsullivan)\
**Post date:** [March 10, 2020, 4:40pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/8 "2020-03-10T16:40:33Z")

</div>

I see. Well thanks, it looks like the error message is making a suggestion towards the solution. It seems the `applicationData.intiatingPassengerRawMrz.keyword` does not have a value in all of the documents, which causes the script to fail.

You can try adding a check for these empty values in the script to avoid the failure. Here's a quick example:

```auto
if (doc['applicationData.intiatingPassengerRawMrz.keyword'].size() == 0) {
  return 'invalid Mrz'
};

```

---

<div class="post-metadata">

**Author:** ![KibanaUser2](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@KibanaUser2](https://discuss.elastic.co/u/KibanaUser2)\
**Post date:** [March 10, 2020, 10:08pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/9 "2020-03-10T22:08:32Z")

</div>

Hi sullivan

I tried all possibilities before reaching out to kibana. Even the above check fails.

```auto
{
 "root_cause": [
  {
   "type": "script_exception",
   "reason": "compile error",
   "script_stack": [
    "... return 'invalid Mrz' ;\n\n};\n",
    " ^---- HERE"
   ],
   "script": "if (doc['applicationData.intiatingPassengerRawMrz.keyword'].size() == 0) {\n\n return 'invalid Mrz' ;\n\n};\n",
   "lang": "painless"
  }
 ],
 "type": "search_phase_execution_exception",
 "reason": "all shards failed",
 "phase": "query",
 "grouped": true,
 "failed_shards": [
  {
   "shard": 0,
   "index": "report-kiosk-session-",
   "node": "zjRc5DLTROSI4UG211ktpg",
   "reason": {
    "type": "script_exception",
    "reason": "compile error",
    "script_stack": [
     "... return 'invalid Mrz' ;\n\n};\n",
     " ^---- HERE"
    ],
    "script": "if (doc['applicationData.intiatingPassengerRawMrz.keyword'].size() == 0) {\n\n return 'invalid Mrz' ;\n\n};\n",
    "lang": "painless",
    "caused_by": {
     "type": "illegal_argument_exception",
     "reason": "unexpected token [';'] was expecting one of [<EOF>]."
    }
   }
  }
 ]
}

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 7, 2020, 10:08pm UTC](https://discuss.elastic.co/t/date-property-is-not-recognised/220738/10 "2020-04-07T22:08:33Z")

</div>

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