# Issues Encountered During Elasticsearch plugin Upgrade from 8.9 to 8.14

**URL:** <https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454>\
**Category:** Elasticsearch\
**Created:** [July 3, 2024, 11:32am UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454 "2024-07-03T11:32:08Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramsankar](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@ramsankar](https://discuss.elastic.co/u/ramsankar)\
**Post date:** [July 3, 2024, 11:32am UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/1 "2024-07-03T11:32:08Z")

</div>

We are working on upgrading Elasticsearch plugin from version 8.9 to 8.14 and encountering issues. We have modified the following constructor:

**In 8.9:**

```auto
highlighter = new CustomUnifiedHighlighter(
    searcher,
    analyzer,
    offsetSource,
    passageFormatter,
    highlighterContext.field.fieldOptions().boundaryScannerLocale(),
    breakIterator,
    highlighterContext.context.getIndexName(),
    highlighterContext.fieldName,
    highlighterContext.query,
    highlighterContext.field.fieldOptions().noMatchSize(),
    highlighterNumberOfFragments,
    fieldMatcher(highlighterContext),
    maxAnalyzedOffset,
    highlighterContext.field.fieldOptions().maxAnalyzedOffset()
);

```

**In 8.14:**

```auto
UnifiedHighlighter.Builder builder = new UnifiedHighlighter.Builder(searcher, analyzer);

highlighter = new CustomUnifiedHighlighter(
    builder,
    offsetSource,
    highlighterContext.field.fieldOptions().boundaryScannerLocale(),
    highlighterContext.context.getIndexName(),
    highlighterContext.fieldName,
    highlighterContext.query,
    highlighterContext.field.fieldOptions().noMatchSize(),
    highlighterNumberOfFragments,
    maxAnalyzedOffset,
    highlighterContext.field.fieldOptions().maxAnalyzedOffset(),
    true,
    true
);

```

We are encountering the following error when calling `highlighter.highlightField`, which is part of `CustomUnifiedHighlighter.class`:

```auto
"reason": {
    "type": "class_cast_exception",
    "reason": "class java.lang.String cannot be cast to class [Lorg.elasticsearch.lucene.search.uhighlight.Snippet; (java.lang.String is in module java.base of loader 'bootstrap'; [Lorg.elasticsearch.lucene.search.uhighlight.Snippet; is in module org.elasticsearch.server@8.14.1 of loader 'app')"
}

```

Happy to share more info regarding the query if required and suggestions are appreciated.  
Thank you!!

---

<div class="post-metadata">

**Author:** ![carly.richmond](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carly.richmond/32/104935_2.png) [@carly.richmond](https://discuss.elastic.co/u/carly.richmond)\
**Post date:** [July 3, 2024, 12:26pm UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/2 "2024-07-03T12:26:26Z")

</div>

Hi @ramsankar,

It looks like you're using the [Elasticsearch Java client](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/index.html). Can you confirm which version of the client you are using?

---

<div class="post-metadata">

**Author:** ![ramsankar](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@ramsankar](https://discuss.elastic.co/u/ramsankar)\
**Post date:** [July 3, 2024, 12:42pm UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/3 "2024-07-03T12:42:17Z")

</div>

Hi @ramsankar,

Please see the information below:  
It's located in POM.xml.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/d/bd5abd6c4e2d0925d075c033062452f0df4f562b.png)

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [July 4, 2024, 2:30am UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/4 "2024-07-04T02:30:18Z")

</div>

> [@ramsankar](#):
>
> We are working on upgrading Elasticsearch from version 8.9 to 8.14 and encountering issues. We have modified the following constructor

Are you working on a plugin, or have you modified Elasticsearch itself?  
What code have you modified that needs to use `CustomUnifiedHighlighter` ?

---

<div class="post-metadata">

**Author:** ![ramsankar](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@ramsankar](https://discuss.elastic.co/u/ramsankar)\
**Post date:** [July 4, 2024, 4:30am UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/5 "2024-07-04T04:30:05Z")

</div>

We are focusing solely on the plugin and not modifying anything in Elasticsearch itself. We haven't made any changes to the `CustomUnifiedHighlighter.class`. The code I shared is part of our `.java` class, which we updated for version compatibility. This is the major change we made to the plugin when upgrading from 8.9 to 8.14. While version 8.9 worked as expected, we are encountering issues with version 8.14.

---

<div class="post-metadata">

**Author:** ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)\
**Post date:** [July 4, 2024, 6:12am UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/6 "2024-07-04T06:12:17Z")

</div>

Your original post doesn't mention that you're building a plugin, you've left us to try and guess what you're doing.

Can you try to explain your problem again with more detail about what you're actually building?

---

<div class="post-metadata">

**Author:** ![ramsankar](https://avatars.discourse-cdn.com/v4/letter/r/b9bd4f/32.png) [@ramsankar](https://discuss.elastic.co/u/ramsankar)\
**Post date:** [July 4, 2024, 10:54am UTC](https://discuss.elastic.co/t/issues-encountered-during-elasticsearch-plugin-upgrade-from-8-9-to-8-14/362454/7 "2024-07-04T10:54:48Z")

</div>

We are working on upgrading the plugin from Elasticsearch version 8.9 to 8.14. To ensure compatibility, we modified the `highlighter = new CustomUnifiedHighlighter(...)` constructor in the plugin as per the 8.14 version requirements. When we call the `highlighter.highlightField()` method, from FreTextHighlighter.java (internal), which returns the snippet and is part of the `CustomUnifiedHighlighter.class`, we encounter the error mentioned earlier.

We have verified that there are no changes in the `CustomUnifiedHighlighter.class` between versions 8.9 and 8.14. Therefore, we suspect the issue is triggered by the modifications we made to the `highlighter = new CustomUnifiedHighlighter(...)` constructor (as shared in the initial query). However, we have not been able to identify the exact cause of the problem.

The error occurs on line 148:

> <https://github.com/elastic/elasticsearch/blob/8.14/server/src/main/java/org/elasticsearch/lucene/search/uhighlight/CustomUnifiedHighlighter.java>

We apologize for not sharing this information clearly in our previous communication.
