-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix issue with returning incomplete fragment for plain highlighter. #110707
Fix issue with returning incomplete fragment for plain highlighter. #110707
Conversation
Pinging @elastic/es-search (Team:Search) |
Hi @ioanatia, I've created a changelog YAML for you. |
@@ -218,6 +218,9 @@ private static int findGoodEndForNoHighlightExcerpt(int noMatchSize, Analyzer an | |||
// Can't split on term boundaries without offsets | |||
return -1; | |||
} | |||
if (contents.length() <= noMatchSize) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move this to like 216, even before analyzing contents
string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was asking myself the same, but I think the behaviour would not be consistent which could cause confusion - when no offsets are provided we would some return highlights for some document fields, but not for others and the reason why that happens might not be apparent.
If that's not actually a problem I am okay to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking more about it, you are right. It is better to have the consistent behaviour. Let's keep your changes as they are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ioanatia Thanks for fixing, +1 to merge after addressing my small. comment
…lastic#110707) * Fix issue with noMatchSize for plain highlighter * Update docs/changelog/110707.yaml
💔 Backport failed
You can use sqren/backport to manually backport by running |
This is a bug that was noticed in the context of App Search which uses the plain highlighter.
It seems that when the text field value is ending in special characters and
no_match_size
is equal or greater than the size of the text, we are not returning the full text.This is because in
findGoodEndForNoHighlightExcerpt
we are consuming the token stream and we just return the position of where the last token ends, thus ignoring any special characters the original text might end with that are not part of a token.Steps to replicate:
response - the highlight is
)hey
instead of)hey)
: