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