Skip to content

Commit 10aeff3

Browse files
committed
Add highlighting for match_only_text type
Signed-off-by: Eugene Tolbakov <[email protected]>
1 parent e15f712 commit 10aeff3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/src/main/java/org/opensearch/search/fetch/subphase/highlight/HighlightPhase.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ private Map<String, Function<HitContext, FieldHighlightContext>> contextBuilders
152152
continue;
153153
}
154154

155-
// We should prevent highlighting if a field is anything but a text or keyword field.
155+
// We should prevent highlighting if a field is anything but a text, match_only_text
156+
// or keyword field.
156157
// However, someone might implement a custom field type that has text and still want to
157158
// highlight on that. We cannot know in advance if the highlighter will be able to
158159
// highlight such a field and so we do the following:
@@ -162,7 +163,8 @@ private Map<String, Function<HitContext, FieldHighlightContext>> contextBuilders
162163
// what they were doing and try to highlight anyway.
163164
if (fieldNameContainsWildcards) {
164165
if (fieldType.typeName().equals(TextFieldMapper.CONTENT_TYPE) == false
165-
&& fieldType.typeName().equals(KeywordFieldMapper.CONTENT_TYPE) == false) {
166+
&& fieldType.typeName().equals(KeywordFieldMapper.CONTENT_TYPE) == false
167+
&& fieldType.typeName().equals("match_only_text") == false) {
166168
continue;
167169
}
168170
if (highlighter.canHighlight(fieldType) == false) {

0 commit comments

Comments
 (0)