james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [5/7] james-project git commit: JAMES-2137 Introduce FullText search capability
Date Fri, 08 Sep 2017 20:14:53 GMT
JAMES-2137 Introduce FullText search capability


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ad33cef8
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ad33cef8
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ad33cef8

Branch: refs/heads/master
Commit: ad33cef8f4ad0ac0feae8a4a323690871f1e311c
Parents: f319cd3
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Wed Sep 6 11:18:40 2017 +0200
Committer: Antoine Duprat <aduprat@linagora.com>
Committed: Fri Sep 8 21:56:59 2017 +0200

----------------------------------------------------------------------
 .../apache/james/mailbox/MailboxManager.java    |  1 +
 ...lasticSearchListeningMessageSearchIndex.java |  2 +-
 .../search/SimpleMessageSearchIndexTest.java    |  9 ++---
 .../store/search/SimpleMessageSearchIndex.java  |  2 +-
 .../search/AbstractMessageSearchIndexTest.java  | 41 ++++++++++++++------
 .../james/JamesCapabilitiesServerTest.java      |  4 +-
 .../java/org/apache/james/jmap/JMAPModule.java  |  4 +-
 7 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index f0b3eb1..0a34607 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -103,6 +103,7 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport
{
          *  From, To, Cc, Bcc, Subjects, textBody & htmlBody
          */
         Text,
+        FullText,
         Attachment
     }
     

http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
index 34c0d2b..f36ffdb 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMessageSearchIndex.java
@@ -78,7 +78,7 @@ public class ElasticSearchListeningMessageSearchIndex extends ListeningMessageSe
 
     @Override
     public EnumSet<SearchCapabilities> getSupportedCapabilities() {
-        return EnumSet.of(SearchCapabilities.MultimailboxSearch, SearchCapabilities.Text,
SearchCapabilities.Attachment);
+        return EnumSet.of(SearchCapabilities.MultimailboxSearch, SearchCapabilities.Text,
SearchCapabilities.FullText, SearchCapabilities.Attachment);
     }
     
     @Override

http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
index 9d5f2ba..da2c267 100644
--- a/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
+++ b/mailbox/scanning-search/src/test/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndexTest.java
@@ -228,7 +228,7 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
 
     @Ignore
     @Override
-    public void searchWithFullTextShouldReturnMailsWhenTextBodyMatchesAndNonContinuousWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenTextBodyMatchesAndNonContinuousWords()
throws Exception {
     }
 
     @Ignore
@@ -238,17 +238,16 @@ public class SimpleMessageSearchIndexTest extends AbstractMessageSearchIndexTest
 
     @Ignore
     @Override
-    public void searchWithFullTextShouldReturnMailsWhenHtmlBodyMatchesAndNonContinuousWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenHtmlBodyMatchesAndNonContinuousWords()
throws Exception {
     }
 
     @Ignore
     @Override
-    public void searchWithFullTextShouldReturnMailsWhenTextBodyWithExtraUnindexedWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenTextBodyWithExtraUnindexedWords() throws
Exception {
     }
 
     @Ignore
     @Override
-    public void searchWithFullTextShouldReturnMailsWhenHtmlBodyMatchesWithStemming() throws
Exception {
+    public void searchWithTextShouldReturnMailsWhenHtmlBodyMatchesWithStemming() throws Exception
{
     }
-
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
index 9a301b4..6388fff 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/SimpleMessageSearchIndex.java
@@ -77,7 +77,7 @@ public class SimpleMessageSearchIndex implements MessageSearchIndex {
     
     @Override
     public EnumSet<SearchCapabilities> getSupportedCapabilities() {
-        return EnumSet.of(SearchCapabilities.MultimailboxSearch, SearchCapabilities.Text,
SearchCapabilities.Attachment);
+        return EnumSet.of(SearchCapabilities.MultimailboxSearch, SearchCapabilities.Text,
SearchCapabilities.FullText, SearchCapabilities.Attachment);
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
index a2686f3..9fc2062 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/search/AbstractMessageSearchIndexTest.java
@@ -999,7 +999,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnNoMailWhenNotMatching() throws Exception {
+    public void searchWithTextShouldReturnNoMailWhenNotMatching() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("unmatching"));
 
@@ -1008,7 +1008,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenFromMatches() throws Exception {
+    public void searchWithTextShouldReturnMailsWhenFromMatches() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("spam.minet.net"));
 
@@ -1017,7 +1017,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenToMatches() throws Exception {
+    public void searchWithTextShouldReturnMailsWhenToMatches() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("listes.minet.net"));
 
@@ -1026,7 +1026,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenCcMatches() throws Exception {
+    public void searchWithTextShouldReturnMailsWhenCcMatches() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("abc.org"));
 
@@ -1035,7 +1035,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenBccMatches() throws Exception {
+    public void searchWithTextShouldReturnMailsWhenBccMatches() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("any.com"));
 
@@ -1044,7 +1044,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenTextBodyMatches() throws Exception
{
+    public void searchWithTextShouldReturnMailsWhenTextBodyMatches() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("reviewing work"));
 
@@ -1054,7 +1054,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenTextBodyMatchesAndNonContinuousWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenTextBodyMatchesAndNonContinuousWords()
throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("reviewing feature"));
         // 2: text/plain contains: "Issue Type: New Feature"
@@ -1065,7 +1065,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenTextBodyMatchesInsensitiveWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenTextBodyMatchesInsensitiveWords() throws
Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("reVieWing"));
         // text/plain contains: "We are reviewing work I did for this feature."
@@ -1075,7 +1075,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenTextBodyWithExtraUnindexedWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenTextBodyWithExtraUnindexedWords() throws
Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("a reviewing of
the work"));
         // text/plain contains: "We are reviewing work I did for this feature."
@@ -1085,7 +1085,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenHtmlBodyMatches() throws Exception
{
+    public void searchWithTextShouldReturnMailsWhenHtmlBodyMatches() throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("contains a banana"));
         // text/html contains: "This is a mail with beautifull html content which contains
a banana."
@@ -1095,7 +1095,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenHtmlBodyMatchesWithStemming() throws
Exception {
+    public void searchWithTextShouldReturnMailsWhenHtmlBodyMatchesWithStemming() throws Exception
{
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("contain banana"));
 
@@ -1104,7 +1104,7 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
-    public void searchWithFullTextShouldReturnMailsWhenHtmlBodyMatchesAndNonContinuousWords()
throws Exception {
+    public void searchWithTextShouldReturnMailsWhenHtmlBodyMatchesAndNonContinuousWords()
throws Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Text));
         SearchQuery searchQuery = new SearchQuery(SearchQuery.textContains("beautifull banana"));
 
@@ -1113,6 +1113,23 @@ public abstract class AbstractMessageSearchIndexTest {
     }
 
     @Test
+    public void searchWithFulTextShouldReturnMailsWhenToAndBodyAndAttachmentMatches() throws
Exception {
+        Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.FullText));
+        ComposedMessageId messageWithBeautifulBananaAsTextAttachment = myFolderMessageManager.appendMessage(
+                ClassLoader.getSystemResourceAsStream("eml/emailWithTextAttachment.eml"),
+                new Date(1404252000000L),
+                session,
+                RECENT,
+                new Flags());
+        await();
+
+        SearchQuery searchQuery = new SearchQuery(SearchQuery.mailContains("User message
banana"));
+
+        assertThat(messageSearchIndex.search(session, mailbox2, searchQuery))
+            .containsExactly(messageWithBeautifulBananaAsTextAttachment.getUid());
+    }
+
+    @Test
     public void searchWithTextAttachmentShouldReturnMailsWhenAttachmentContentMatches() throws
Exception {
         Assume.assumeTrue(storeMailboxManager.getSupportedSearchCapabilities().contains(MailboxManager.SearchCapabilities.Attachment));
         ComposedMessageId messageWithBeautifulBananaAsTextAttachment = myFolderMessageManager.appendMessage(

http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
index cedaccb..e0f447c 100644
--- a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/JamesCapabilitiesServerTest.java
@@ -101,14 +101,14 @@ public class JamesCapabilitiesServerTest {
     }
     
     @Test
-    public void startShouldFailWhenNoTextCapability() throws Exception {
+    public void startShouldFailWhenNoFullTextCapability() throws Exception {
         MailboxManager mailboxManager = mock(MailboxManager.class);
         when(mailboxManager.getSupportedMailboxCapabilities())
             .thenReturn(EnumSet.allOf(MailboxManager.MailboxCapabilities.class));
         when(mailboxManager.getSupportedMessageCapabilities())
             .thenReturn(EnumSet.allOf(MailboxManager.MessageCapabilities.class));
         when(mailboxManager.getSupportedSearchCapabilities())
-            .thenReturn(EnumSet.complementOf(EnumSet.of(MailboxManager.SearchCapabilities.Text)));
+            .thenReturn(EnumSet.complementOf(EnumSet.of(MailboxManager.SearchCapabilities.FullText)));
 
         server = createCassandraJamesServer(mailboxManager);
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/ad33cef8/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
index 88de16a..9150680 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -151,8 +151,8 @@ public class JMAPModule extends AbstractModule {
             EnumSet<SearchCapabilities> searchCapabilities = mailboxManager.getSupportedSearchCapabilities();
             Preconditions.checkArgument(searchCapabilities.contains(MailboxManager.SearchCapabilities.MultimailboxSearch),
                     "Multimailbox search in MailboxManager is required by JMAP Module");
-            Preconditions.checkArgument(searchCapabilities.contains(MailboxManager.SearchCapabilities.Text),
-                    "Text support in MailboxManager is required by JMAP Module");
+            Preconditions.checkArgument(searchCapabilities.contains(MailboxManager.SearchCapabilities.FullText),
+                    "FullText support in MailboxManager is required by JMAP Module");
             Preconditions.checkArgument(searchCapabilities.contains(MailboxManager.SearchCapabilities.Attachment),
                     "Attachment Search support in MailboxManager is required by JMAP Module");
         }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message