You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by "hungphan227 (via GitHub)" <gi...@apache.org> on 2025/01/06 08:06:36 UTC
[PR] JAMES-4100 Improve Search Snippet display [james-project]
hungphan227 opened a new pull request, #2583:
URL: https://github.com/apache/james-project/pull/2583
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2591809326
> LGTM but did you try to run locally related tests though? Would be surprised that everything is green :)
Fixed inmailbox/lucene/src/main/java/org/apache/james/mailbox/lucene/search/LuceneSearchHighlighter.java
Sth wrong with CI. Need to restart CI
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2603662884
`03:21:52,863 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-remote-resources-plugin:1.6.0:process (default) on project apache-mailet-ai: Execution default of goal org.apache.maven.plugins:maven-remote-resources-plugin:1.6.0:process failed: Could not acquire lock(s)`
@Arsnael could you help me restart?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2606135637
https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-2583/8/testReport/
Related
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2576894585
Have you tried
StringUtils.remove(s, '>);
Or
CharMatcher.is('>').removeFrom(s)
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1922202829
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/IndexableMessage.java:
##########
@@ -135,8 +135,8 @@ private Mono<IndexableMessage> instantiateIndexedMessage() throws IOException, M
.asMimePart(textExtractor)
.map(parsingResult -> {
- Optional<String> bodyText = parsingResult.locateFirstTextBody();
- Optional<String> bodyHtml = parsingResult.locateFirstHtmlBody();
+ Optional<String> bodyText = parsingResult.locateFirstTextBody().map(SearchUtil::removeGreaterThanCharacters);
+ Optional<String> bodyHtml = parsingResult.locateFirstHtmlBody().map(SearchUtil::removeGreaterThanCharacters);
Review Comment:
Ok I don't know it does not happen in html case. Will remove
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa merged PR #2583:
URL: https://github.com/apache/james-project/pull/2583
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2576962309
> I do not know: how would it look like in the end user display?
Example:
Input: >>>>>>>>>> append contentA to >>> inbox >>>>>>
Result: > append <mark>contentA</mark> to > inbox >
(<mark>contentA</mark> is the highlighted part)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1905137556
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java:
##########
@@ -100,6 +97,21 @@ private SearchSnippet buildSearchSnippet(Hit<ObjectNode> searchResult) {
}
private String shortenGreaterThanCharacters(String text) {
- return GREATER_THAN_PATTERN.matcher(text).replaceAll(">");
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
Review Comment:
I am a fan of neither of both approaches to be fairly honnest..
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2577267818
> I wonder if `append contentA to INBOX` wouldn't be better...
The solution for this is not just `StringUtils.remove(s, '>);`. We should not remove > from <mark> tag of search snippet.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1912887815
##########
mailbox/api/src/main/java/org/apache/james/mailbox/SearchUtil.java:
##########
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox;
+
+public class SearchUtil {
+ public static String shortenGreaterThanCharacters(String text) {
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
+ if (c == '>') {
+ if (!previousIsTarget) {
+ result.append(c);
+ previousIsTarget = true;
+ }
+ } else {
+ result.append(c);
+ previousIsTarget = false;
+ }
+ }
+
+ return result.toString();
+ }
Review Comment:
Maybe we should shorten if, and only if previous character is `\n` ? And completly remove > isf previous char is `\n`
```
>> abc def
>> ghi klm
```
=>
```
abc def
ghi klm
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2576640330
https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-2583/1/testReport/
Related I believe
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2591895917
Can we have a look at how it looks like with the frontend?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1914634427
##########
mailbox/api/src/main/java/org/apache/james/mailbox/SearchUtil.java:
##########
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox;
+
+public class SearchUtil {
+ public static String shortenGreaterThanCharacters(String text) {
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
+ if (c == '>') {
+ if (!previousIsTarget) {
+ result.append(c);
+ previousIsTarget = true;
+ }
+ } else {
+ result.append(c);
+ previousIsTarget = false;
+ }
+ }
+
+ return result.toString();
+ }
Review Comment:
Ok. What if there are space characters between \n and > like this?
```
abc def
>> ghi klm
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2576926858
I do not know: how would it look like in the end user display?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1922120128
##########
mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SearchUtil.java:
##########
@@ -473,5 +473,22 @@ public boolean test(MessageId input) {
};
}
+ public static String removeGreaterThanCharacters(String text) {
Review Comment:
Please indicate in the name that it is at the beginning of a line.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2586121311
@hungphan227 Status of this?
Tests still not fixed I believe => https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-2583/1/testReport/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2586165280
Actually I don't know what I should do.
Either removing all `>` or keeping just one `>`, there is no way to make it simple like `StringUtils.remove(s, '>);`. I know only two ways: either using regex or a loop to iterate through the string.
Therefore, I suggest closing this ticket and leave things as before. Anyway removing > is not really important.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2576916627
> Have you tried
>
> StringUtils.remove(s, '>);
>
> Or
>
> CharMatcher.is('>').removeFrom(s)
>
> ?
Don't you want to keep at least one character after removing?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1923013418
##########
mailbox/api/src/test/java/org/apache/james/mailbox/searchhighligt/SearchHighLighterContract.java:
##########
@@ -532,4 +532,43 @@ default void shouldHighLightBodyWhenHTMLBodyMatched() throws Exception {
softly.assertThat(searchSnippets.getFirst().highlightedBody().get()).contains("<mark>barcamp</mark>");
});
}
+
+ @Test
+ default void highlightSearchShouldShortenGreaterThanCharacters() throws Exception {
+ MailboxSession session = session(USERNAME1);
+
+ // Given m1,m2 with m1 has body containing the searched word (contentA)
+ ComposedMessageId m1 = appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setTo("to@james.local")
+ .setSubject("Hallo, Thx Matthieu for your help")
+ .setBody("Start \n>>>>>>>>>> append contentA to > inbox \n>>>>>> End",
+ StandardCharsets.UTF_8)),
+ session).getId();
+
+ ComposedMessageId m2 = appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setTo("to@james.local")
+ .setSubject("Hallo, Thx Alex for your help")
+ .setBody("append contentB to inbox", StandardCharsets.UTF_8)),
+ session).getId();
+
+ verifyMessageWasIndexed(2);
+
+ // When searching for the word (contentA) in the body
+ MultimailboxesSearchQuery multiMailboxSearch = MultimailboxesSearchQuery.from(SearchQuery.of(
+ SearchQuery.bodyContains("contentA")))
+ .inMailboxes(List.of(m1.getMailboxId(), m2.getMailboxId()))
+ .build();
+
+ // Then highlightSearch should return the SearchSnippet with the highlightedBody containing the word (contentA)
+ List<SearchSnippet> searchSnippets = Flux.from(testee().highlightSearch(List.of(m1.getMessageId(), m2.getMessageId()), multiMailboxSearch, session))
+ .collectList()
+ .block();
+ assertThat(searchSnippets).hasSize(1);
+ assertSoftly(softly -> {
+ softly.assertThat(searchSnippets.getFirst().messageId()).isEqualTo(m1.getMessageId());
+ softly.assertThat(searchSnippets.getFirst().highlightedBody().get()).isEqualTo("Start \n append <mark>contentA</mark> to > inbox \n End");
Review Comment:
sr did not know it has been done. Test fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1914805001
##########
mailbox/api/src/main/java/org/apache/james/mailbox/SearchUtil.java:
##########
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox;
+
+public class SearchUtil {
+ public static String shortenGreaterThanCharacters(String text) {
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
+ if (c == '>') {
+ if (!previousIsTarget) {
+ result.append(c);
+ previousIsTarget = true;
+ }
+ } else {
+ result.append(c);
+ previousIsTarget = false;
+ }
+ }
+
+ return result.toString();
+ }
Review Comment:
Generally `>>` quotes are at the begining of lines I presume.
If in doubt then take some sample email and run this locally to see how it looks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1914404344
##########
mailbox/api/src/main/java/org/apache/james/mailbox/SearchUtil.java:
##########
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox;
+
+public class SearchUtil {
+ public static String shortenGreaterThanCharacters(String text) {
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
+ if (c == '>') {
+ if (!previousIsTarget) {
+ result.append(c);
+ previousIsTarget = true;
+ }
+ } else {
+ result.append(c);
+ previousIsTarget = false;
+ }
+ }
+
+ return result.toString();
+ }
Review Comment:
The issue clearly leaves margin for decision to the author and suggest `>>>` could be removed.
Please let's try to follow `Maybe we should shorten if, and only if previous character is \n ? And completly remove > isf previous char is \n`. Ok?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2591827122
> Sth wrong with CI. Need to restart CI
=> https://github.com/apache/james-project/pull/2599 is what's wrong with the CI :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "quantranhong1999 (via GitHub)" <gi...@apache.org>.
quantranhong1999 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2574379874
Lucene tests failed: https://ci-builds.apache.org/job/james/job/ApacheJames/job/PR-2583/1/testReport/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2586431128
Ok
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1914225900
##########
mailbox/api/src/main/java/org/apache/james/mailbox/SearchUtil.java:
##########
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox;
+
+public class SearchUtil {
+ public static String shortenGreaterThanCharacters(String text) {
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
+ if (c == '>') {
+ if (!previousIsTarget) {
+ result.append(c);
+ previousIsTarget = true;
+ }
+ } else {
+ result.append(c);
+ previousIsTarget = false;
+ }
+ }
+
+ return result.toString();
+ }
Review Comment:
I have no idea. I don't see such thing in the image you posted https://github.com/linagora/james-project/issues/5340#issue-2683469911
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1922123038
##########
mailbox/api/src/test/java/org/apache/james/mailbox/searchhighligt/SearchHighLighterContract.java:
##########
@@ -532,4 +532,43 @@ default void shouldHighLightBodyWhenHTMLBodyMatched() throws Exception {
softly.assertThat(searchSnippets.getFirst().highlightedBody().get()).contains("<mark>barcamp</mark>");
});
}
+
+ @Test
+ default void highlightSearchShouldShortenGreaterThanCharacters() throws Exception {
+ MailboxSession session = session(USERNAME1);
+
+ // Given m1,m2 with m1 has body containing the searched word (contentA)
+ ComposedMessageId m1 = appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setTo("to@james.local")
+ .setSubject("Hallo, Thx Matthieu for your help")
+ .setBody("Start \n>>>>>>>>>> append contentA to > inbox \n>>>>>> End",
+ StandardCharsets.UTF_8)),
+ session).getId();
+
+ ComposedMessageId m2 = appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setTo("to@james.local")
+ .setSubject("Hallo, Thx Alex for your help")
+ .setBody("append contentB to inbox", StandardCharsets.UTF_8)),
+ session).getId();
+
+ verifyMessageWasIndexed(2);
+
+ // When searching for the word (contentA) in the body
+ MultimailboxesSearchQuery multiMailboxSearch = MultimailboxesSearchQuery.from(SearchQuery.of(
+ SearchQuery.bodyContains("contentA")))
+ .inMailboxes(List.of(m1.getMailboxId(), m2.getMailboxId()))
+ .build();
+
+ // Then highlightSearch should return the SearchSnippet with the highlightedBody containing the word (contentA)
+ List<SearchSnippet> searchSnippets = Flux.from(testee().highlightSearch(List.of(m1.getMessageId(), m2.getMessageId()), multiMailboxSearch, session))
+ .collectList()
+ .block();
+ assertThat(searchSnippets).hasSize(1);
+ assertSoftly(softly -> {
+ softly.assertThat(searchSnippets.getFirst().messageId()).isEqualTo(m1.getMessageId());
+ softly.assertThat(searchSnippets.getFirst().highlightedBody().get()).isEqualTo("Start \n append <mark>contentA</mark> to > inbox \n End");
Review Comment:
shouldn't this lone `>` be html encoded?
Otherwise text plain stuff may be leveraged for HTML injections...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1922118159
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/IndexableMessage.java:
##########
@@ -135,8 +135,8 @@ private Mono<IndexableMessage> instantiateIndexedMessage() throws IOException, M
.asMimePart(textExtractor)
.map(parsingResult -> {
- Optional<String> bodyText = parsingResult.locateFirstTextBody();
- Optional<String> bodyHtml = parsingResult.locateFirstHtmlBody();
+ Optional<String> bodyText = parsingResult.locateFirstTextBody().map(SearchUtil::removeGreaterThanCharacters);
+ Optional<String> bodyHtml = parsingResult.locateFirstHtmlBody().map(SearchUtil::removeGreaterThanCharacters);
Review Comment:
Do this make sense on the HTML body which uses `<quote>previous message</quote>` ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1922194254
##########
mailbox/api/src/test/java/org/apache/james/mailbox/searchhighligt/SearchHighLighterContract.java:
##########
@@ -532,4 +532,43 @@ default void shouldHighLightBodyWhenHTMLBodyMatched() throws Exception {
softly.assertThat(searchSnippets.getFirst().highlightedBody().get()).contains("<mark>barcamp</mark>");
});
}
+
+ @Test
+ default void highlightSearchShouldShortenGreaterThanCharacters() throws Exception {
+ MailboxSession session = session(USERNAME1);
+
+ // Given m1,m2 with m1 has body containing the searched word (contentA)
+ ComposedMessageId m1 = appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setTo("to@james.local")
+ .setSubject("Hallo, Thx Matthieu for your help")
+ .setBody("Start \n>>>>>>>>>> append contentA to > inbox \n>>>>>> End",
+ StandardCharsets.UTF_8)),
+ session).getId();
+
+ ComposedMessageId m2 = appendMessage(MessageManager.AppendCommand.from(
+ Message.Builder.of()
+ .setTo("to@james.local")
+ .setSubject("Hallo, Thx Alex for your help")
+ .setBody("append contentB to inbox", StandardCharsets.UTF_8)),
+ session).getId();
+
+ verifyMessageWasIndexed(2);
+
+ // When searching for the word (contentA) in the body
+ MultimailboxesSearchQuery multiMailboxSearch = MultimailboxesSearchQuery.from(SearchQuery.of(
+ SearchQuery.bodyContains("contentA")))
+ .inMailboxes(List.of(m1.getMailboxId(), m2.getMailboxId()))
+ .build();
+
+ // Then highlightSearch should return the SearchSnippet with the highlightedBody containing the word (contentA)
+ List<SearchSnippet> searchSnippets = Flux.from(testee().highlightSearch(List.of(m1.getMessageId(), m2.getMessageId()), multiMailboxSearch, session))
+ .collectList()
+ .block();
+ assertThat(searchSnippets).hasSize(1);
+ assertSoftly(softly -> {
+ softly.assertThat(searchSnippets.getFirst().messageId()).isEqualTo(m1.getMessageId());
+ softly.assertThat(searchSnippets.getFirst().highlightedBody().get()).isEqualTo("Start \n append <mark>contentA</mark> to > inbox \n End");
Review Comment:
We can create another ticket for this issue
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2601900621
Updated to remove before indexing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1905096344
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java:
##########
@@ -100,6 +97,21 @@ private SearchSnippet buildSearchSnippet(Hit<ObjectNode> searchResult) {
}
private String shortenGreaterThanCharacters(String text) {
- return GREATER_THAN_PATTERN.matcher(text).replaceAll(">");
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
Review Comment:
Should I use regex?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1903851436
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java:
##########
@@ -90,8 +93,13 @@ 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);
return new SearchSnippet(messageId, highlightedSubject, highlightedTextBody);
}
+
+ private String shortenGreaterThanCharacters(String text) {
+ return GREATER_THAN_PATTERN.matcher(text).replaceAll(">");
+ }
Review Comment:
Could we get a shot at a non regexp implementation of this please?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1903911269
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java:
##########
@@ -100,6 +97,21 @@ private SearchSnippet buildSearchSnippet(Hit<ObjectNode> searchResult) {
}
private String shortenGreaterThanCharacters(String text) {
- return GREATER_THAN_PATTERN.matcher(text).replaceAll(">");
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
Review Comment:
I have doubts about char iteration method.
Maybe we could bench with JMH this version and the REGEXP one?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "hungphan227 (via GitHub)" <gi...@apache.org>.
hungphan227 commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1904882105
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java:
##########
@@ -100,6 +97,21 @@ private SearchSnippet buildSearchSnippet(Hit<ObjectNode> searchResult) {
}
private String shortenGreaterThanCharacters(String text) {
- return GREATER_THAN_PATTERN.matcher(text).replaceAll(">");
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
Review Comment:
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)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "vttranlina (via GitHub)" <gi...@apache.org>.
vttranlina commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1904912196
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/search/OpenSearchSearchHighlighter.java:
##########
@@ -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);
Review Comment:
Rename it to `prettyHighlightedText` or `foldHighlightedText` is better?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2577038441
I wonder if `append contentA to INBOX` wouldn't be better...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "Arsnael (via GitHub)" <gi...@apache.org>.
Arsnael commented on PR #2583:
URL: https://github.com/apache/james-project/pull/2583#issuecomment-2586330223
> Anyway removing > is not really important.
An end user might disagree with you on that I think :)
Honestly I get that removing entirely the trailings `>` is tricky and might require a non efficient process as you need to be careful with initial `>` potentially present in the message (and you don't want to break the <mark> tags)
I would be ok with the initial solution, aka folding `>>>>>` into `>` but need to fix current breaking related tests.
@chibenwa what are your thoughts here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1912887815
##########
mailbox/api/src/main/java/org/apache/james/mailbox/SearchUtil.java:
##########
@@ -0,0 +1,41 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox;
+
+public class SearchUtil {
+ public static String shortenGreaterThanCharacters(String text) {
+ StringBuilder result = new StringBuilder();
+ boolean previousIsTarget = false;
+
+ for (char c : text.toCharArray()) {
+ if (c == '>') {
+ if (!previousIsTarget) {
+ result.append(c);
+ previousIsTarget = true;
+ }
+ } else {
+ result.append(c);
+ previousIsTarget = false;
+ }
+ }
+
+ return result.toString();
+ }
Review Comment:
Maybe we should shorten if, and only if previous character is `\n` ? And completly remove > isf previous char is `\n`
```
>> abc def
>> ghi klm
```
=>
```
abc def
ghi klm
```
WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org
Re: [PR] JAMES-4100 Improve Search Snippet display [james-project]
Posted by "chibenwa (via GitHub)" <gi...@apache.org>.
chibenwa commented on code in PR #2583:
URL: https://github.com/apache/james-project/pull/2583#discussion_r1922179985
##########
mailbox/opensearch/src/main/java/org/apache/james/mailbox/opensearch/json/IndexableMessage.java:
##########
@@ -135,8 +135,8 @@ private Mono<IndexableMessage> instantiateIndexedMessage() throws IOException, M
.asMimePart(textExtractor)
.map(parsingResult -> {
- Optional<String> bodyText = parsingResult.locateFirstTextBody();
- Optional<String> bodyHtml = parsingResult.locateFirstHtmlBody();
+ Optional<String> bodyText = parsingResult.locateFirstTextBody().map(SearchUtil::removeGreaterThanCharacters);
+ Optional<String> bodyHtml = parsingResult.locateFirstHtmlBody().map(SearchUtil::removeGreaterThanCharacters);
Review Comment:
Take this message:

The corresponding HTML body is:

Which do not quote with `>...` but with `<blockquote>...</blockquote>` so removing `>>>` at the beginning of line for `text/html` is indeed a non-sense with well-formatted non testing data.
Can you provide us with real world data where removing `>>>` for HTML body makes sense?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org