-
Notifications
You must be signed in to change notification settings - Fork 473
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
JAMES-4100 Improve Search Snippet display #2583
base: master
Are you sure you want to change the base?
JAMES-4100 Improve Search Snippet display #2583
Conversation
...ch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java
Outdated
Show resolved
Hide resolved
StringBuilder result = new StringBuilder(); | ||
boolean previousIsTarget = false; | ||
|
||
for (char c : text.toCharArray()) { |
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.
I have doubts about char iteration method.
Maybe we could bench with JMH this version and the REGEXP one?
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.
Tested both ways with JMH in an isolated test (run method shortenGreaterThanCharacters in a loop with 10000 iterations). Both have the same results (around 3ms)
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 I use regex?
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.
I am a fan of neither of both approaches to be fairly honnest..
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.
Read it, nothing to add
Lucene tests failed: https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-2583/1/testReport/ |
@@ -90,8 +90,28 @@ private SearchSnippet buildSearchSnippet(Hit<ObjectNode> searchResult) { | |||
Optional<String> highlightedTextBody = Optional.ofNullable(highlightHit.get(JsonMessageConstants.TEXT_BODY)) | |||
.or(() -> Optional.ofNullable(highlightHit.get(JsonMessageConstants.HTML_BODY))) | |||
.or(() -> Optional.ofNullable(highlightHit.get(ATTACHMENT_TEXT_CONTENT_FIELD))) | |||
.map(List::getFirst); | |||
.map(List::getFirst) | |||
.map(this::shortenGreaterThanCharacters); |
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.
Rename it to prettyHighlightedText
or foldHighlightedText
is better?
Have you tried StringUtils.remove(s, '>); Or CharMatcher.is('>').removeFrom(s) ? |
Don't you want to keep at least one character after removing? |
I do not know: how would it look like in the end user display? |
Example: (contentA is the highlighted part) |
I wonder if |
The solution for this is not just |
No description provided.