Issues Encountered During Elasticsearch plugin Upgrade from 8.9 to 8.14

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:

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:

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:

"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!!

Hi @ramsankar,

It looks like you're using the Elasticsearch Java client. Can you confirm which version of the client you are using?

Hi @ramsankar,

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

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

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.

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?

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:

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