You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ro...@apache.org on 2016/11/30 15:38:11 UTC

[1/2] james-project git commit: JAMES-1867 Add parameter for indexing attachments or not

Repository: james-project
Updated Branches:
  refs/heads/master 7bcc6201b -> 868765716


JAMES-1867 Add parameter for indexing attachments or not


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

Branch: refs/heads/master
Commit: fe5a6a498642cfc1d5b476e2b1d954b3139148ab
Parents: 7bcc620
Author: Laura Royet <lr...@linagora.com>
Authored: Mon Nov 28 14:01:58 2016 +0100
Committer: Laura Royet <lr...@linagora.com>
Committed: Wed Nov 30 15:32:35 2016 +0100

----------------------------------------------------------------------
 .../mailbox/elasticsearch/IndexAttachments.java | 25 +++++++++
 .../elasticsearch/json/IndexableMessage.java    | 18 +++++--
 .../json/MessageToElasticSearchJson.java        |  3 +-
 .../json/IndexableMessageTest.java              | 57 +++++++++++++++++---
 .../src/test/resources/eml/Toto.eml             | 41 ++++++++++++++
 5 files changed, 130 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/fe5a6a49/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexAttachments.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexAttachments.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexAttachments.java
new file mode 100644
index 0000000..6d45eed
--- /dev/null
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/IndexAttachments.java
@@ -0,0 +1,25 @@
+/****************************************************************
+ * 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.elasticsearch;
+
+public enum IndexAttachments {
+
+    NO, YES;
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/fe5a6a49/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
index b474c1b..0896140 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessage.java
@@ -30,6 +30,7 @@ import java.util.stream.Stream;
 
 import org.apache.james.mailbox.MailboxSession.User;
 import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.elasticsearch.query.DateResolutionFormater;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
@@ -41,11 +42,14 @@ import com.github.steveash.guavate.Guavate;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Strings;
 import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Multimap;
 
 public class IndexableMessage {
 
-    public static IndexableMessage from(MailboxMessage message, List<User> users, TextExtractor textExtractor, ZoneId zoneId) {
+    public static IndexableMessage from(MailboxMessage message, List<User> users, TextExtractor textExtractor, 
+            ZoneId zoneId, IndexAttachments indexAttachments) {
+
         Preconditions.checkNotNull(message.getMailboxId());
         Preconditions.checkArgument(!users.isEmpty());
         IndexableMessage indexableMessage = new IndexableMessage();
@@ -54,7 +58,7 @@ public class IndexableMessage {
             indexableMessage.users = users.stream().map(User::getUserName).collect(Guavate.toImmutableList());
             indexableMessage.bodyText = parsingResult.locateFirstTextBody();
             indexableMessage.bodyHtml = parsingResult.locateFirstHtmlBody();
-            indexableMessage.setFlattenedAttachments(parsingResult);
+            indexableMessage.setFlattenedAttachments(parsingResult, indexAttachments);
             indexableMessage.copyHeaderFields(parsingResult.getHeaderCollection(), getSanitizedInternalDate(message, zoneId));
             indexableMessage.generateText();
         } catch (IOException | MimeException e) {
@@ -64,9 +68,13 @@ public class IndexableMessage {
         return indexableMessage;
     }
 
-    private void setFlattenedAttachments(MimePart parsingResult) {
-        attachments = parsingResult.getAttachmentsStream()
-            .collect(Collectors.toList());
+    private void setFlattenedAttachments(MimePart parsingResult, IndexAttachments indexAttachments) {
+        if (indexAttachments.equals(IndexAttachments.YES)) {
+            attachments = parsingResult.getAttachmentsStream()
+                    .collect(Collectors.toList());
+        } else {
+            attachments = ImmutableList.of();
+        }
     }
 
     private void copyHeaderFields(HeaderCollection headerCollection, ZonedDateTime internalDate) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/fe5a6a49/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
index dd27a6e..8e9ca86 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
@@ -26,6 +26,7 @@ import javax.inject.Inject;
 import javax.mail.Flags;
 
 import org.apache.james.mailbox.MailboxSession.User;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.mail.model.MailboxMessage;
 
@@ -56,7 +57,7 @@ public class MessageToElasticSearchJson {
 
     public String convertToJson(MailboxMessage message, List<User> users) throws JsonProcessingException {
         Preconditions.checkNotNull(message);
-        return mapper.writeValueAsString(IndexableMessage.from(message, users, textExtractor, zoneId));
+        return mapper.writeValueAsString(IndexableMessage.from(message, users, textExtractor, zoneId, IndexAttachments.NO));
     }
 
     public String getUpdatedJsonMessagePart(Flags flags, long modSeq) throws JsonProcessingException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/fe5a6a49/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessageTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessageTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessageTest.java
index 2a62f2c..930c21c 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessageTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/IndexableMessageTest.java
@@ -29,6 +29,7 @@ import java.time.ZoneId;
 import javax.mail.Flags;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.store.TestId;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
@@ -51,7 +52,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEmpty();
     }
@@ -68,7 +69,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("Second user user2@james.org First user user@james.org");
     }
@@ -85,7 +86,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("First to user@james.org Second to user2@james.org");
     }
@@ -102,7 +103,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("First cc user@james.org Second cc user2@james.org");
     }
@@ -119,7 +120,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("Second bcc user2@james.org First bcc user@james.org");
     }
@@ -136,7 +137,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("subject1 subject2");
     }
@@ -153,7 +154,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("My body");
     }
@@ -170,7 +171,7 @@ public class IndexableMessageTest {
             .thenReturn(new Flags());
 
         IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
-                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"));
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
 
         assertThat(indexableMessage.getText()).isEqualTo("Ad Min admin@opush.test " +
                 "a@test a@test B b@test " + 
@@ -182,4 +183,44 @@ public class IndexableMessageTest {
                 "-- \n" + 
                 "Ad Min\n");
     }
+
+    @Test
+    public void attachmentsShouldNotBeenIndexedWhenAsked() throws Exception {
+        //Given
+        MailboxMessage mailboxMessage = mock(MailboxMessage.class);
+        TestId mailboxId = TestId.of(1);
+        when(mailboxMessage.getMailboxId())
+            .thenReturn(mailboxId);
+        when(mailboxMessage.getFullContent())
+            .thenReturn(new ByteArrayInputStream(IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/Toto.eml"))));
+        when(mailboxMessage.createFlags())
+            .thenReturn(new Flags());
+
+        // When
+        IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.NO);
+
+        // Then
+        assertThat(indexableMessage.getAttachments()).isEmpty();
+    }
+
+    @Test
+    public void attachmentsShouldBeenIndexedWhenAsked() throws Exception {
+        //Given
+        MailboxMessage mailboxMessage = mock(MailboxMessage.class);
+        TestId mailboxId = TestId.of(1);
+        when(mailboxMessage.getMailboxId())
+            .thenReturn(mailboxId);
+        when(mailboxMessage.getFullContent())
+            .thenReturn(new ByteArrayInputStream(IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/Toto.eml"))));
+        when(mailboxMessage.createFlags())
+            .thenReturn(new Flags());
+
+        // When
+        IndexableMessage indexableMessage = IndexableMessage.from(mailboxMessage, ImmutableList.of(new MockMailboxSession("username").getUser()),
+                new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES);
+
+        // Then
+        assertThat(indexableMessage.getAttachments()).isNotEmpty();
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/fe5a6a49/mailbox/elasticsearch/src/test/resources/eml/Toto.eml
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/resources/eml/Toto.eml b/mailbox/elasticsearch/src/test/resources/eml/Toto.eml
new file mode 100644
index 0000000..ab2de03
--- /dev/null
+++ b/mailbox/elasticsearch/src/test/resources/eml/Toto.eml
@@ -0,0 +1,41 @@
+Return-Path: <lr...@linagora.com>
+Received: from alderaan.linagora.com (smtp.linagora.dc1 [172.16.18.53])
+	 by imap (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA;
+	 Tue, 29 Nov 2016 13:57:56 +0100
+X-Sieve: CMU Sieve 2.2
+Received: from [10.69.0.146] (mne69-10-88-173-78-196.fbx.proxad.net [88.173.78.196])
+	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
+	(No client certificate requested)
+	by alderaan.linagora.com (Postfix) with ESMTPSA id CB0233783
+	for <lr...@linagora.com>; Tue, 29 Nov 2016 13:57:56 +0100 (CET)
+To: Laura ROYET <lr...@linagora.com>
+From: Laura Royet <lr...@linagora.com>
+Subject: Toto
+Message-ID: <25...@linagora.com>
+Date: Tue, 29 Nov 2016 13:57:56 +0100
+User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
+ Thunderbird/45.5.0
+MIME-Version: 1.0
+Content-Type: multipart/mixed;
+ boundary="------------3F646081DC313215FD6847F4"
+
+This is a multi-part message in MIME format.
+--------------3F646081DC313215FD6847F4
+Content-Type: text/plain; charset=utf-8; format=flowed
+Content-Transfer-Encoding: 7bit
+
+
+
+-- 
+Laura Royet
+
+
+--------------3F646081DC313215FD6847F4
+Content-Type: text/plain; charset=UTF-8;
+ name="Toto.txt"
+Content-Transfer-Encoding: base64
+Content-Disposition: attachment;
+ filename="Toto.txt"
+
+VG90bwpDb3B5cmlnaHQgwqkgMjAxNiBMSU5BR09SQSAKQ0MgQlktU0EsIEdOVSBGREwK
+--------------3F646081DC313215FD6847F4--


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


[2/2] james-project git commit: JAMES-1867 Add indexAttachments in ElasticSearch configuration

Posted by ro...@apache.org.
JAMES-1867 Add indexAttachments in ElasticSearch configuration


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

Branch: refs/heads/master
Commit: 86876571665bdff85b71511e824a8be53080aa54
Parents: fe5a6a4
Author: Laura Royet <lr...@linagora.com>
Authored: Mon Nov 28 14:54:48 2016 +0100
Committer: Laura Royet <lr...@linagora.com>
Committed: Wed Nov 30 15:37:16 2016 +0100

----------------------------------------------------------------------
 .../destination/conf/elasticsearch.properties   |   2 +
 .../json/MessageToElasticSearchJson.java        |  10 +-
 .../ElasticSearchIntegrationTest.java           |   2 +-
 .../MailboxMessageToElasticSearchJsonTest.java  |  79 ++++++++++++--
 .../eml/recursiveMailWithoutAttachments.json    | 109 +++++++++++++++++++
 .../host/ElasticSearchHostSystem.java           |   3 +-
 .../elasticsearch.properties                    |   4 +-
 .../mailbox/ElasticSearchMailboxModule.java     |  11 ++
 .../mailbox/ElasticSearchMailboxModuleTest.java |  64 +++++++++++
 server/src/site/xdoc/config-elasticsearch.xml   |   2 +
 10 files changed, 267 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/dockerfiles/run/guice/destination/conf/elasticsearch.properties
----------------------------------------------------------------------
diff --git a/dockerfiles/run/guice/destination/conf/elasticsearch.properties b/dockerfiles/run/guice/destination/conf/elasticsearch.properties
index 7ed13a4..a10cd3f 100644
--- a/dockerfiles/run/guice/destination/conf/elasticsearch.properties
+++ b/dockerfiles/run/guice/destination/conf/elasticsearch.properties
@@ -26,3 +26,5 @@ elasticsearch.nb.shards=1
 elasticsearch.nb.replica=0
 elasticsearch.retryConnection.maxRetries=7
 elasticsearch.retryConnection.minDelay=3000
+# Index or not attachments (default value: true)
+elasticsearch.indexAttachments=true

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
index 8e9ca86..b6d97e9 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/json/MessageToElasticSearchJson.java
@@ -41,23 +41,25 @@ public class MessageToElasticSearchJson {
     private final ObjectMapper mapper;
     private final TextExtractor textExtractor;
     private final ZoneId zoneId;
+    private final IndexAttachments indexAttachments;
 
-    public MessageToElasticSearchJson(TextExtractor textExtractor, ZoneId zoneId) {
+    public MessageToElasticSearchJson(TextExtractor textExtractor, ZoneId zoneId, IndexAttachments indexAttachments) {
         this.textExtractor = textExtractor;
         this.zoneId = zoneId;
+        this.indexAttachments = indexAttachments;
         this.mapper = new ObjectMapper();
         this.mapper.registerModule(new GuavaModule());
         this.mapper.registerModule(new Jdk8Module());
     }
 
     @Inject
-    public MessageToElasticSearchJson(TextExtractor textExtractor) {
-        this(textExtractor, ZoneId.systemDefault());
+    public MessageToElasticSearchJson(TextExtractor textExtractor, IndexAttachments indexAttachments) {
+        this(textExtractor, ZoneId.systemDefault(), indexAttachments);
     }
 
     public String convertToJson(MailboxMessage message, List<User> users) throws JsonProcessingException {
         Preconditions.checkNotNull(message);
-        return mapper.writeValueAsString(IndexableMessage.from(message, users, textExtractor, zoneId, IndexAttachments.NO));
+        return mapper.writeValueAsString(IndexableMessage.from(message, users, textExtractor, zoneId, indexAttachments));
     }
 
     public String getUpdatedJsonMessagePart(Flags flags, long modSeq) throws JsonProcessingException {

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
index a60a747..6a43e0d 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIntegrationTest.java
@@ -71,7 +71,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
         messageSearchIndex = new ElasticSearchListeningMessageSearchIndex(mapperFactory,
             new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), BATCH_SIZE)),
             new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE, new InMemoryId.Factory()),
-            new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris")));
+            new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES));
         MessageId.Factory messageIdFactory = new DefaultMessageId.Factory();
         storeMailboxManager = new InMemoryMailboxManager(
             mapperFactory,

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/MailboxMessageToElasticSearchJsonTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/MailboxMessageToElasticSearchJsonTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/MailboxMessageToElasticSearchJsonTest.java
index 0a47807..77c0bf1 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/MailboxMessageToElasticSearchJsonTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/json/MailboxMessageToElasticSearchJsonTest.java
@@ -35,6 +35,7 @@ import javax.mail.util.SharedByteArrayInputStream;
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mailbox.FlagsBuilder;
 import org.apache.james.mailbox.MailboxSession.User;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.mock.MockMailboxSession;
 import org.apache.james.mailbox.model.MessageId;
@@ -80,7 +81,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void convertToJsonShouldThrowWhenNoUser() throws Exception {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
                 new DefaultTextExtractor(),
-                ZoneId.of("Europe/Paris"));
+                ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID,
                 date,
                 SIZE,
@@ -99,7 +100,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void spamEmailShouldBeWellConvertedToJson() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID,
                 date,
                 SIZE,
@@ -119,7 +120,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void htmlEmailShouldBeWellConvertedToJson() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage htmlMail = new SimpleMailboxMessage(MESSAGE_ID,
                 date,
                 SIZE,
@@ -139,7 +140,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void pgpSignedEmailShouldBeWellConvertedToJson() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage pgpSignedMail = new SimpleMailboxMessage(MESSAGE_ID,
                 date,
                 SIZE,
@@ -159,7 +160,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void simpleEmailShouldBeWellConvertedToJson() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage mail = new SimpleMailboxMessage(MESSAGE_ID,
                 date,
                 SIZE,
@@ -180,7 +181,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void recursiveEmailShouldBeWellConvertedToJson() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage recursiveMail = new SimpleMailboxMessage(MESSAGE_ID, 
                 date,
                 SIZE,
@@ -200,7 +201,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void emailWithNoInternalDateShouldUseNowDate() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage mailWithNoInternalDate = new SimpleMailboxMessage(MESSAGE_ID,
                 null,
                 SIZE,
@@ -217,11 +218,65 @@ public class MailboxMessageToElasticSearchJsonTest {
             .isEqualTo(IOUtils.toString(ClassLoader.getSystemResource("eml/recursiveMail.json")));
     }
 
+    @Test
+    public void emailWithAttachmentsShouldConvertAttachmentsWhenIndexAttachmentsIsTrue() throws IOException {
+        // Given
+        MailboxMessage mailWithNoInternalDate = new SimpleMailboxMessage(MESSAGE_ID,
+                null,
+                SIZE,
+                BODY_START_OCTET,
+                new SharedByteArrayInputStream(IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/recursiveMail.eml"))),
+                new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.SEEN).add("debian", "security").build(),
+                propertyBuilder,
+                MAILBOX_ID);
+        mailWithNoInternalDate.setModSeq(MOD_SEQ);
+        mailWithNoInternalDate.setUid(UID);
+
+        // When
+        MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
+            new DefaultTextExtractor(),
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
+        String convertToJson = messageToElasticSearchJson.convertToJson(mailWithNoInternalDate, ImmutableList.of(new MockMailboxSession("username").getUser()));
+
+        // Then
+        assertThatJson(convertToJson)
+            .when(IGNORING_ARRAY_ORDER)
+            .when(IGNORING_VALUES)
+            .isEqualTo(IOUtils.toString(ClassLoader.getSystemResource("eml/recursiveMail.json")));
+    }
+
+    @Test
+    public void emailWithAttachmentsShouldNotConvertAttachmentsWhenIndexAttachmentsIsFalse() throws IOException {
+        // Given
+        MailboxMessage mailWithNoInternalDate = new SimpleMailboxMessage(MESSAGE_ID,
+                null,
+                SIZE,
+                BODY_START_OCTET,
+                new SharedByteArrayInputStream(IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/recursiveMail.eml"))),
+                new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.SEEN).add("debian", "security").build(),
+                propertyBuilder,
+                MAILBOX_ID);
+        mailWithNoInternalDate.setModSeq(MOD_SEQ);
+        mailWithNoInternalDate.setUid(UID);
+        
+        // When
+        MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
+            new DefaultTextExtractor(),
+            ZoneId.of("Europe/Paris"), IndexAttachments.NO);
+        String convertToJson = messageToElasticSearchJson.convertToJson(mailWithNoInternalDate, ImmutableList.of(new MockMailboxSession("username").getUser()));
+
+        // Then
+        assertThatJson(convertToJson)
+            .when(IGNORING_ARRAY_ORDER)
+            .when(IGNORING_VALUES)
+            .isEqualTo(IOUtils.toString(ClassLoader.getSystemResource("eml/recursiveMailWithoutAttachments.json")));
+    }
+
     @Test(expected = NullPointerException.class)
     public void emailWithNoMailboxIdShouldThrow() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage mailWithNoMailboxId;
         try {
             mailWithNoMailboxId = new SimpleMailboxMessage(MESSAGE_ID, date,
@@ -243,7 +298,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void getUpdatedJsonMessagePartShouldBehaveWellOnEmptyFlags() throws Exception {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         assertThatJson(messageToElasticSearchJson.getUpdatedJsonMessagePart(new Flags(), MOD_SEQ))
             .isEqualTo("{\"modSeq\":42,\"isAnswered\":false,\"isDeleted\":false,\"isDraft\":false,\"isFlagged\":false,\"isRecent\":false,\"userFlags\":[],\"isUnread\":true}");
     }
@@ -252,7 +307,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void getUpdatedJsonMessagePartShouldBehaveWellOnNonEmptyFlags() throws Exception {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         assertThatJson(messageToElasticSearchJson.getUpdatedJsonMessagePart(new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.FLAGGED).add("user").build(), MOD_SEQ))
             .isEqualTo("{\"modSeq\":42,\"isAnswered\":false,\"isDeleted\":true,\"isDraft\":false,\"isFlagged\":true,\"isRecent\":false,\"userFlags\":[\"user\"],\"isUnread\":true}");
     }
@@ -261,7 +316,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void getUpdatedJsonMessagePartShouldThrowIfFlagsIsNull() throws Exception {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new DefaultTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         messageToElasticSearchJson.getUpdatedJsonMessagePart(null, MOD_SEQ);
     }
 
@@ -269,7 +324,7 @@ public class MailboxMessageToElasticSearchJsonTest {
     public void spamEmailShouldBeWellConvertedToJsonWithApacheTika() throws IOException {
         MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
             new TikaTextExtractor(),
-            ZoneId.of("Europe/Paris"));
+            ZoneId.of("Europe/Paris"), IndexAttachments.YES);
         MailboxMessage spamMail = new SimpleMailboxMessage(MESSAGE_ID, date,
             SIZE,
             BODY_START_OCTET,

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/mailbox/store/src/test/resources/eml/recursiveMailWithoutAttachments.json
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/resources/eml/recursiveMailWithoutAttachments.json b/mailbox/store/src/test/resources/eml/recursiveMailWithoutAttachments.json
new file mode 100644
index 0000000..c17741e
--- /dev/null
+++ b/mailbox/store/src/test/resources/eml/recursiveMailWithoutAttachments.json
@@ -0,0 +1,109 @@
+{
+  "id": 25,
+  "mailboxId": "18",
+  "modSeq": 42,
+  "size": 25,
+  "date": "2015-06-07T00:00:00+02:00",
+  "mediaType": "plain",
+  "subtype": "text",
+  "userFlags": [
+    "security",
+    "debian"
+  ],
+  "headers": {
+    "date": [
+      "Wed, 10 Jun 2015 10:45:27 +0200"
+    ],
+    "mime-version": [
+      "1.0"
+    ],
+    "in-reply-to": [
+      "<55...@linagora.com>"
+    ],
+    "references": [
+      "<55...@linagora.com>"
+    ],
+    "return-path": [
+      "<mb...@linagora.com>"
+    ],
+    "x-forwarded-message-id": [
+      "<55...@linagora.com>"
+    ],
+    "subject": [
+      "Fwd: Courbe Sprint"
+    ],
+    "received": [
+      "from alderaan.linagora.com (smtp.linagora.dc1 [172.16.18.53])\t by imap (Cyrus v2.2.13-Debian-2.2.13-19+squeeze3) with LMTPA;\t Wed, 10 Jun 2015 10:45:29 +0200",
+      "from [10.69.2.28] (mne69-10-88-173-78-196.fbx.proxad.net [88.173.78.196])\t(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))\t(No client certificate requested)\tby alderaan.linagora.com (Postfix) with ESMTPSA id 7F33E728\tfor <bt...@linagora.com>; Wed, 10 Jun 2015 10:45:28 +0200 (CEST)"
+    ],
+    "x-sieve": [
+      "CMU Sieve 2.2"
+    ],
+    "message-id": [
+      "<55...@linagora.com>"
+    ],
+    "from": [
+      "Matthieu Baechler <mb...@linagora.com>"
+    ],
+    "content-type": [
+      "multipart/mixed; boundary=\"------------080603090509090707040003\""
+    ],
+    "to": [
+      "btellier@linagora.com"
+    ],
+    "user-agent": [
+      "Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0"
+    ]
+  },
+  "from": [
+    {
+      "name": "Matthieu Baechler",
+      "address": "mbaechler@linagora.com"
+    }
+  ],
+  "to": [
+    {
+      "name": "btellier@linagora.com",
+      "address": "btellier@linagora.com"
+    }
+  ],
+  "cc": [],
+  "bcc": [],
+  "replyTo": [],
+  "subject": [
+    "Fwd: Courbe Sprint"
+  ],
+  "sentDate": "2015-06-10T10:45:27+02:00",
+  "properties": [
+    {
+      "namespace": "http://james.apache.org/rfc2045/Content-Type",
+      "localName": "type",
+      "value": "plain"
+    },
+    {
+      "namespace": "http://james.apache.org/rfc2045/Content-Type",
+      "localName": "subtype",
+      "value": "text"
+    },
+    {
+      "namespace": "http://james.apache.org/rfc2045",
+      "localName": "Content-Description",
+      "value": "An e-mail"
+    }
+  ],
+  "attachments": [
+  ],
+  "textBody": "Forward as attachment !\n\n\n",
+  "htmlBody": null,
+  "isDraft": false,
+  "isFlagged": true,
+  "isRecent": false,
+  "isAnswered": false,
+  "isDeleted": true,
+  "hasAttachment": true,
+  "isUnread": false,
+  "users": [
+    "username"
+  ],
+  "text": "Matthieu Baechler mbaechler@linagora.com btellier@linagora.com btellier@linagora.com Fwd: Courbe Sprint Forward as attachment !\n\n\n"
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
index 3fc1893..e9943fc 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/elasticsearch/src/test/java/org/apache/james/mpt/imapmailbox/elasticsearch/host/ElasticSearchHostSystem.java
@@ -35,6 +35,7 @@ import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.elasticsearch.DeleteByQueryPerformer;
 import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
 import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
@@ -109,7 +110,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
             factory,
             new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor())),
             new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), new InMemoryId.Factory()),
-            new MessageToElasticSearchJson(new DefaultTextExtractor()));
+            new MessageToElasticSearchJson(new DefaultTextExtractor(), IndexAttachments.YES));
 
         MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
         GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties b/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
index 924404c..67b280b 100644
--- a/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
+++ b/server/container/guice/cassandra-guice/sample-configuration/elasticsearch.properties
@@ -23,4 +23,6 @@
 elasticsearch.masterHost=172.17.0.1
 elasticsearch.port=9300
 elasticsearch.nb.shards=1
-elasticsearch.nb.replica=0
\ No newline at end of file
+elasticsearch.nb.replica=0
+# Index or not attachments (default value: true)
+elasticsearch.indexAttachments=true

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
index 0ea91bf..15878dd 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModule.java
@@ -29,6 +29,7 @@ import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.james.filesystem.api.FileSystem;
 import org.apache.james.mailbox.elasticsearch.ClientProvider;
 import org.apache.james.mailbox.elasticsearch.ClientProviderImpl;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
 import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
 import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
@@ -48,6 +49,7 @@ public class ElasticSearchMailboxModule extends AbstractModule {
 
     private static final int DEFAULT_CONNECTION_MAX_RETRIES = 7;
     private static final int DEFAULT_CONNECTION_MIN_DELAY = 3000;
+    private static final boolean DEFAULT_INDEX_ATTACHMENTS = true;
 
     @Override
     protected void configure() {
@@ -83,4 +85,13 @@ public class ElasticSearchMailboxModule extends AbstractModule {
                 .withMinDelay(configuration.getInt("elasticsearch.retryConnection.minDelay", DEFAULT_CONNECTION_MIN_DELAY));
     }
 
+    @Provides 
+    @Singleton
+    public IndexAttachments provideIndexAttachments(PropertiesConfiguration configuration) {
+        if (configuration.getBoolean("elasticsearch.indexAttachments", DEFAULT_INDEX_ATTACHMENTS)) {
+            return IndexAttachments.YES;
+        }
+        return IndexAttachments.NO;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModuleTest.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModuleTest.java b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModuleTest.java
new file mode 100644
index 0000000..26e3cc5
--- /dev/null
+++ b/server/container/guice/cassandra-guice/src/test/java/org/apache/james/modules/mailbox/ElasticSearchMailboxModuleTest.java
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.modules.mailbox;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.mailbox.elasticsearch.IndexAttachments;
+import org.junit.Test;
+
+public class ElasticSearchMailboxModuleTest {
+
+    @Test
+    public void provideIndexAttachmentsShouldReturnTrueWhenIndexAttachmentsIsTrueInConfiguration() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("elasticsearch.indexAttachments", true);
+
+        ElasticSearchMailboxModule testee = new ElasticSearchMailboxModule();
+
+        IndexAttachments indexAttachments = testee.provideIndexAttachments(configuration);
+
+        assertThat(indexAttachments).isEqualTo(IndexAttachments.YES);
+    }
+
+    @Test
+    public void provideIndexAttachmentsShouldReturnFalseWhenIndexAttachmentsIsFalseInConfiguration() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+        configuration.addProperty("elasticsearch.indexAttachments", false);
+
+        ElasticSearchMailboxModule testee = new ElasticSearchMailboxModule();
+
+        IndexAttachments indexAttachments = testee.provideIndexAttachments(configuration);
+
+        assertThat(indexAttachments).isEqualTo(IndexAttachments.NO);
+    }
+
+    @Test
+    public void provideIndexAttachmentsShouldReturnTrueWhenIndexAttachmentsIsNotDefinedInConfiguration() {
+        PropertiesConfiguration configuration = new PropertiesConfiguration();
+
+        ElasticSearchMailboxModule testee = new ElasticSearchMailboxModule();
+
+        IndexAttachments indexAttachments = testee.provideIndexAttachments(configuration);
+
+        assertThat(indexAttachments).isEqualTo(IndexAttachments.YES);
+    }
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/86876571/server/src/site/xdoc/config-elasticsearch.xml
----------------------------------------------------------------------
diff --git a/server/src/site/xdoc/config-elasticsearch.xml b/server/src/site/xdoc/config-elasticsearch.xml
index d2ce7cd..3b5cd2c 100644
--- a/server/src/site/xdoc/config-elasticsearch.xml
+++ b/server/src/site/xdoc/config-elasticsearch.xml
@@ -34,6 +34,8 @@
         <dd>Is the name of the cluster used by James.</dd>
         <dt><strong>elasticsearch.masterHost</strong></dt>
         <dd>Is the IP (or host) of the ElasticSearch master</dd>
+        <dt><strong>elasticsearch.indexAttachments</strong></dt>
+        <dd>Indicates if you wish to index attachments or not (default: true).</dd>
       </dl>
 
 <p>If you want more explanation about ElasticSearch configuration, you should visit the dedicated <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html">documentation</a>.</p>


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