# 8.14.0 Migration : Unknown field 'preserve\_original'

**URL:** <https://discuss.elastic.co/t/8-14-0-migration-unknown-field-preserve-original/366975>\
**Category:** Elasticsearch\
**Created:** [September 23, 2024, 3:40pm UTC](https://discuss.elastic.co/t/8-14-0-migration-unknown-field-preserve-original/366975 "2024-09-23T15:40:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![John.Doe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john.doe/32/137776_2.png) [@John.Doe](https://discuss.elastic.co/u/John.Doe)\
**Post date:** [September 23, 2024, 3:40pm UTC](https://discuss.elastic.co/t/8-14-0-migration-unknown-field-preserve-original/366975/1 "2024-09-23T15:40:22Z")

</div>

Hi,

I am trying to migrate to version 8.14.0.  
In my filter mapping, I have the following filter :

```auto
"leadingZeroTrim": 
{
  "type": "pattern_replace",
  "preserve_original": "true",
  "pattern": "^0+(.*)",
  "replacement": "$1"
}

```

It didn't cause any errors in versions before 8.14.0, although it seems that the `preserve_original` field doesn't work with the `pattern_replace` type.

It is from version 8.14.0 that this mapping returns an error when using the `PutTemplateRequest.Builder().withJson(java.io.Reader)` method.

The error is :

```auto
co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch._types.analysis.PatternReplaceTokenFilter: Unknown field 'preserve_original'

```

Can you confirm that this error is indeed the expected behavior ?  
If so, how to reproduce the behavior of the field `preserve_original` in my filter ?

Thank you in advance !

---

<div class="post-metadata">

**Author:** ![ltrotta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ltrotta/32/124003_2.png) [@ltrotta](https://discuss.elastic.co/u/ltrotta)\
**Post date:** [September 23, 2024, 4:06pm UTC](https://discuss.elastic.co/t/8-14-0-migration-unknown-field-preserve-original/366975/2 "2024-09-23T16:06:59Z")

</div>

Hello! I went back as far as 7.15, but I cannot find a version of `PatternReplaceTokenFilter` which supported the `preserve_original` parameter. The API for filters is one of those in the elasticsearch server which can accept any parameter, for example this request works perfectly fine:

```auto
GET /_analyze
{
  "tokenizer": "whitespace",
  "filter": [
    {
      "type": "pattern_replace",
      "pattern": "(dog)",
      "replacement": "watch$1",
      "anything" : "really!"
    }
  ],
  "text": "foxes jump lazy dogs"
}

```

So I'm suspecting `preserve_original` wasn't supported, but was accepted anyways, unless it's an even older version that the ones I checked.

Could you let me know which version are you trying to migrate from?

---

<div class="post-metadata">

**Author:** ![John.Doe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john.doe/32/137776_2.png) [@John.Doe](https://discuss.elastic.co/u/John.Doe)\
**Post date:** [September 23, 2024, 5:21pm UTC](https://discuss.elastic.co/t/8-14-0-migration-unknown-field-preserve-original/366975/3 "2024-09-23T17:21:31Z")

</div>

Hello, I am talking about the Elasticsearch Java API Client :

```auto
<dependency>
    <groupId>co.elastic.clients</groupId>
    <artifactId>elasticsearch-java</artifactId>
    <version>8.14.0</version>
</dependency>

```

I apologize for not making this clear from the start!  
I am trying to migrate from 8.10.2 to 8.15.0, but it seems that the problem appears from 8.14.0.

Then, if the `preserve_original` field is not allowed with the `pattern_replace` type, how are we supposed to do ?

---

<div class="post-metadata">

**Author:** ![John.Doe](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/john.doe/32/137776_2.png) [@John.Doe](https://discuss.elastic.co/u/John.Doe)\
**Post date:** [September 23, 2024, 5:22pm UTC](https://discuss.elastic.co/t/8-14-0-migration-unknown-field-preserve-original/366975/4 "2024-09-23T17:22:34Z")

</div>

Tags updated on September 23, 2024, 5:22pm UTC

Removed #language-clients
