# Error: can not write type \[class java.time.LocalDate\] - Elasticsearch v8.10

**URL:** <https://discuss.elastic.co/t/error-can-not-write-type-class-java-time-localdate-elasticsearch-v8-10/350868>\
**Category:** Elasticsearch\
**Created:** [January 11, 2024, 2:39pm UTC](https://discuss.elastic.co/t/error-can-not-write-type-class-java-time-localdate-elasticsearch-v8-10/350868 "2024-01-11T14:39:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Abhishek](https://avatars.discourse-cdn.com/v4/letter/a/7ba0ec/32.png) [@Abhishek](https://discuss.elastic.co/u/Abhishek)\
**Post date:** [January 11, 2024, 2:39pm UTC](https://discuss.elastic.co/t/error-can-not-write-type-class-java-time-localdate-elasticsearch-v8-10/350868/1 "2024-01-11T14:39:34Z")

</div>

Hi Everyone,  
I have recently upgraded from es 5.6 to es 8.10.  
Following script field is working fine in es5.6

```auto
"script_fields": {
      "customDate": {
      "script": {
         "inline": "def i ; if(params._source.customDate == null && params._source.remainder != null ) {
				def cd = params._source.exDate;
				def df = DateTimeFormatter.ofPattern(\"MM/dd/yyyy\"); 
				def localDate = LocalDate.parse(cd,df); 
				if(doc['remainderType'].value=='day') { i = localDate.minusDays(doc['remainder'].value); } 
				else if(doc['remainderType'].value=='month') { i = localDate.minusMonths(doc['remainder'].value); } 
				else if(doc['remainderType'].value=='year') { i = localDate.minusYears(doc['remainder'].value); } 
				} 
			    else if(params._source.customDate != null) {
				i = params._source.customDate 
				}
		  return i"
      }
   }
}

```

field mapping:

```auto
"customDate": {
          "type": "date",
          "format": "MM/dd/yyyy"
        },
"remainder": {
          "type": "long"
        },
"exDate": {
          "type": "date",
          "format": "MM/dd/yyyy",
          "fields": {
            "keyword": {
              "type": "keyword"
            }
          }
        }
"remainderType": {
          "type": "keyword"
        }

```

In es 8.10, it gives following error (response from kibana dev console):

```auto
#! [script][88:20] Deprecated field [inline] used, expected [source] instead
{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "can not write type [class java.time.LocalDate]"
      }
    ],
    "type": "search_phase_execution_exception",
    "reason": "all shards failed",
    "phase": "query",
    "grouped": true,
    "failed_shards": [
      {
        "shard": 0,
        "index": "index_v1",
        "node": "node-A",
        "reason": {
          "type": "illegal_argument_exception",
          "reason": "can not write type [class java.time.LocalDate]"
        }
      }
    ],
    "caused_by": {
      "type": "illegal_argument_exception",
      "reason": "can not write type [class java.time.LocalDate]",
      "caused_by": {
        "type": "illegal_argument_exception",
        "reason": "can not write type [class java.time.LocalDate]"
      }
    }
  },
  "status": 400
}

```

Thanks in advance.

---

<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:** [February 8, 2024, 2:40pm UTC](https://discuss.elastic.co/t/error-can-not-write-type-class-java-time-localdate-elasticsearch-v8-10/350868/2 "2024-02-08T14:40:19Z")

</div>

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