james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [08/12] james-project git commit: JAMES-1901 Create a ElasticSearch backend project
Date Fri, 03 Feb 2017 09:44:36 GMT
http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
new file mode 100644
index 0000000..1cfce9b
--- /dev/null
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/MailboxMappingFactory.java
@@ -0,0 +1,229 @@
+/****************************************************************
+ * 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;
+
+import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
+
+import java.io.IOException;
+
+import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
+import org.elasticsearch.common.xcontent.XContentBuilder;
+
+import com.google.common.base.Throwables;
+
+public class MailboxMappingFactory {
+
+    public static XContentBuilder getMappingContent() {
+        try {
+            return jsonBuilder()
+                .startObject()
+
+                    .startObject(MailboxElasticsearchConstants.MESSAGE_TYPE)
+                        .startObject(NodeMappingFactory.PROPERTIES)
+                            .startObject(JsonMessageConstants.MESSAGE_ID)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.UID)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.LONG)
+                            .endObject()
+                            .startObject(JsonMessageConstants.MODSEQ)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.LONG)
+                            .endObject()
+                            .startObject(JsonMessageConstants.SIZE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.LONG)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_ANSWERED)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_DELETED)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_DRAFT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_FLAGGED)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_RECENT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.IS_UNREAD)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.BOOLEAN)
+                            .endObject()
+                            .startObject(JsonMessageConstants.DATE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.DATE)
+                                .field(NodeMappingFactory.FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
+                            .endObject()
+                            .startObject(JsonMessageConstants.SENT_DATE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.DATE)
+                                .field(NodeMappingFactory.FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
+                            .endObject()
+                            .startObject(JsonMessageConstants.MEDIA_TYPE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.SUBTYPE)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.USER_FLAGS)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.FROM)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .startObject(NodeMappingFactory.FIELDS)
+                                            .startObject(NodeMappingFactory.RAW)
+                                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                                .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                            .endObject()
+                                        .endObject()
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.SUBJECT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .startObject(NodeMappingFactory.FIELDS)
+                                    .startObject(NodeMappingFactory.RAW)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.TO)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .startObject(NodeMappingFactory.FIELDS)
+                                            .startObject(NodeMappingFactory.RAW)
+                                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                                .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                            .endObject()
+                                        .endObject()
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.CC)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.BCC)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.EMailer.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.MAILBOX_ID)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.USERS)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                            .endObject()
+                            .startObject(JsonMessageConstants.PROPERTIES)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.NESTED)
+                                .startObject(NodeMappingFactory.PROPERTIES)
+                                    .startObject(JsonMessageConstants.Property.NAMESPACE)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.Property.NAME)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.INDEX, NodeMappingFactory.NOT_ANALYZED)
+                                    .endObject()
+                                    .startObject(JsonMessageConstants.Property.VALUE)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.TEXT_BODY)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .startObject(NodeMappingFactory.FIELDS)
+                                    .startObject(NodeMappingFactory.RAW)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                        .field(NodeMappingFactory.IGNORE_ABOVE, NodeMappingFactory.LUCENE_LIMIT)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.HTML_BODY)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .startObject(NodeMappingFactory.FIELDS)
+                                    .startObject(NodeMappingFactory.RAW)
+                                        .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                        .field(NodeMappingFactory.ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
+                                        .field(NodeMappingFactory.IGNORE_ABOVE, NodeMappingFactory.LUCENE_LIMIT)
+                                    .endObject()
+                                .endObject()
+                            .endObject()
+
+                            .startObject(JsonMessageConstants.TEXT)
+                                .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
+                                .field(NodeMappingFactory.ANALYZER, NodeMappingFactory.SNOWBALL)
+                                .field(NodeMappingFactory.IGNORE_ABOVE, NodeMappingFactory.LUCENE_LIMIT)
+                            .endObject()
+                        .endObject()
+                    .endObject()
+                .endObject();
+        } catch (IOException e) {
+            throw Throwables.propagate(e);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java
deleted file mode 100644
index 751452c..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/NodeMappingFactory.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/****************************************************************
- * 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;
-
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-
-import java.io.IOException;
-
-import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-
-import com.google.common.base.Throwables;
-
-public class NodeMappingFactory {
-
-    public static final String BOOLEAN = "boolean";
-    public static final String TYPE = "type";
-    public static final String LONG = "long";
-    public static final String INDEX = "index";
-    public static final String NOT_ANALYZED = "not_analyzed";
-    public static final String STRING = "string";
-    public static final String PROPERTIES = "properties";
-    public static final String DATE = "date";
-    public static final String FORMAT = "format";
-    public static final String NESTED = "nested";
-    public static final String FIELDS = "fields";
-    public static final String RAW = "raw";
-    public static final String ANALYZER = "analyzer";
-    public static final String SNOWBALL = "snowball";
-    public static final String IGNORE_ABOVE = "ignore_above";
-    public static final int LUCENE_LIMIT = 32766;
-
-    public static Client applyMapping(Client client) {
-        return applyMapping(client, getMappingContent());
-    }
-
-    public static Client applyMapping(Client client, XContentBuilder mappingsSources) {
-        client.admin()
-            .indices()
-            .preparePutMapping(ElasticSearchIndexer.MAILBOX_INDEX)
-            .setType(ElasticSearchIndexer.MESSAGE_TYPE)
-            .setSource(mappingsSources)
-            .execute()
-            .actionGet();
-        return client;
-    }
-
-    private static XContentBuilder getMappingContent() {
-        try {
-            return jsonBuilder()
-                .startObject()
-
-                    .startObject(ElasticSearchIndexer.MESSAGE_TYPE)
-                        .startObject(PROPERTIES)
-                            .startObject(JsonMessageConstants.MESSAGE_ID)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.UID)
-                                .field(TYPE, LONG)
-                            .endObject()
-                            .startObject(JsonMessageConstants.MODSEQ)
-                                .field(TYPE, LONG)
-                            .endObject()
-                            .startObject(JsonMessageConstants.SIZE)
-                                .field(TYPE, LONG)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_ANSWERED)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_DELETED)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_DRAFT)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_FLAGGED)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_RECENT)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.IS_UNREAD)
-                                .field(TYPE, BOOLEAN)
-                            .endObject()
-                            .startObject(JsonMessageConstants.DATE)
-                                .field(TYPE, DATE)
-                                .field(FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
-                            .endObject()
-                            .startObject(JsonMessageConstants.SENT_DATE)
-                                .field(TYPE, DATE)
-                                .field(FORMAT, "yyyy-MM-dd'T'HH:mm:ssZ")
-                            .endObject()
-                            .startObject(JsonMessageConstants.MEDIA_TYPE)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.SUBTYPE)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.USER_FLAGS)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.FROM)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                        .startObject(FIELDS)
-                                            .startObject(RAW)
-                                                .field(TYPE, STRING)
-                                                .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                            .endObject()
-                                        .endObject()
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.SUBJECT)
-                                .field(TYPE, STRING)
-                                .startObject(FIELDS)
-                                    .startObject(RAW)
-                                        .field(TYPE, STRING)
-                                        .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.TO)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                        .startObject(FIELDS)
-                                            .startObject(RAW)
-                                                .field(TYPE, STRING)
-                                                .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                            .endObject()
-                                        .endObject()
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.CC)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.BCC)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.EMailer.NAME)
-                                        .field(TYPE, STRING)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.EMailer.ADDRESS)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.MAILBOX_ID)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.USERS)
-                                .field(TYPE, STRING)
-                                .field(INDEX, NOT_ANALYZED)
-                            .endObject()
-                            .startObject(JsonMessageConstants.PROPERTIES)
-                                .field(TYPE, NESTED)
-                                .startObject(PROPERTIES)
-                                    .startObject(JsonMessageConstants.Property.NAMESPACE)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.Property.NAME)
-                                        .field(TYPE, STRING)
-                                        .field(INDEX, NOT_ANALYZED)
-                                    .endObject()
-                                    .startObject(JsonMessageConstants.Property.VALUE)
-                                        .field(TYPE, STRING)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.TEXT_BODY)
-                                .field(TYPE, STRING)
-                                .startObject(FIELDS)
-                                    .startObject(RAW)
-                                        .field(TYPE, STRING)
-                                        .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                        .field(IGNORE_ABOVE, LUCENE_LIMIT)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.HTML_BODY)
-                                .field(TYPE, STRING)
-                                .startObject(FIELDS)
-                                    .startObject(RAW)
-                                        .field(TYPE, STRING)
-                                        .field(ANALYZER, IndexCreationFactory.CASE_INSENSITIVE)
-                                        .field(IGNORE_ABOVE, LUCENE_LIMIT)
-                                    .endObject()
-                                .endObject()
-                            .endObject()
-
-                            .startObject(JsonMessageConstants.TEXT)
-                                .field(TYPE, STRING)
-                                .field(ANALYZER, SNOWBALL)
-                                .field(IGNORE_ABOVE, LUCENE_LIMIT)
-                            .endObject()
-                        .endObject()
-                    .endObject()
-                .endObject();
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/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 850dd4c..7372e2b 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
@@ -28,10 +28,10 @@ import java.util.stream.Collectors;
 
 import javax.inject.Inject;
 
+import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
index 05bc3a8..bb11268 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/query/SortConverter.java
@@ -19,7 +19,8 @@
 
 package org.apache.james.mailbox.elasticsearch.query;
 
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.model.SearchQuery;
 import org.elasticsearch.search.sort.FieldSortBuilder;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
index 61bca7e..d8339f7 100644
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
+++ b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ElasticSearchSearcher.java
@@ -26,9 +26,10 @@ import java.util.stream.StreamSupport;
 
 import javax.inject.Inject;
 
+import org.apache.james.backends.es.search.ScrollIterable;
 import org.apache.james.mailbox.MailboxSession.User;
 import org.apache.james.mailbox.MessageUid;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.query.SortConverter;
@@ -82,8 +83,8 @@ public class ElasticSearchSearcher {
         return query.getSearchQuery().getSorts()
             .stream()
             .reduce(
-                client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
+                client.prepareSearch(MailboxElasticsearchConstants.MAILBOX_INDEX)
+                    .setTypes(MailboxElasticsearchConstants.MESSAGE_TYPE)
                     .setScroll(TIMEOUT)
                     .addFields(JsonMessageConstants.UID, JsonMessageConstants.MAILBOX_ID, JsonMessageConstants.MESSAGE_ID)
                     .setQuery(queryConverter.from(users, query))

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java b/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java
deleted file mode 100644
index 76acce1..0000000
--- a/mailbox/elasticsearch/src/main/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterable.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************
- * 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.search;
-
-import java.util.Iterator;
-import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
-
-import org.elasticsearch.action.ListenableActionFuture;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-
-public class ScrollIterable implements Iterable<SearchResponse> {
-
-    private static final TimeValue TIMEOUT = new TimeValue(60000);
-    private final Client client;
-    private final SearchRequestBuilder searchRequestBuilder;
-
-    public ScrollIterable(Client client, SearchRequestBuilder searchRequestBuilder) {
-        this.client = client;
-        this.searchRequestBuilder = searchRequestBuilder;
-    }
-
-    @Override
-    public Iterator<SearchResponse> iterator() {
-        return new ScrollIterator(client, searchRequestBuilder);
-    }
-
-    public Stream<SearchResponse> stream() {
-        return StreamSupport.stream(spliterator(), false);
-    }
-
-    public static class ScrollIterator implements Iterator<SearchResponse> {
-
-        private final Client client;
-        private ListenableActionFuture<SearchResponse> searchResponseFuture;
-
-        public ScrollIterator(Client client, SearchRequestBuilder searchRequestBuilder) {
-            this.client = client;
-            this.searchResponseFuture = searchRequestBuilder.execute();
-        }
-
-        @Override
-        public boolean hasNext() {
-            return !allSearchResponsesConsumed(searchResponseFuture.actionGet());
-        }
-
-        @Override
-        public SearchResponse next() {
-            SearchResponse result = searchResponseFuture.actionGet();
-            searchResponseFuture =  client.prepareSearchScroll(result.getScrollId())
-                .setScroll(TIMEOUT)
-                .execute();
-            return result;
-        }
-
-        private boolean allSearchResponsesConsumed(SearchResponse searchResponse) {
-            return searchResponse.getHits().getHits().length == 0;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java
deleted file mode 100644
index f5f2118..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/ElasticSearchIndexerTest.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/****************************************************************
- * 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;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.elasticsearch.index.query.QueryBuilders.termQuery;
-
-import java.io.IOException;
-import java.util.concurrent.Executors;
-
-import org.apache.james.mailbox.elasticsearch.json.JsonMessageConstants;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
-import org.elasticsearch.action.search.SearchResponse;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.index.query.QueryBuilder;
-import org.elasticsearch.index.query.QueryBuilders;
-import org.elasticsearch.node.Node;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-import com.google.common.collect.Lists;
-
-public class ElasticSearchIndexerTest {
-
-    private static final int MINIMUM_BATCH_SIZE = 1;
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder);
-
-    @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
-    private Node node;
-    private ElasticSearchIndexer testee;
-
-    @Before
-    public void setup() throws IOException {
-        node = embeddedElasticSearch.getNode();
-        TestingClientProvider clientProvider = new TestingClientProvider(node);
-        DeleteByQueryPerformer deleteByQueryPerformer = new DeleteByQueryPerformer(clientProvider.get(), Executors.newSingleThreadExecutor(), MINIMUM_BATCH_SIZE) {
-            @Override
-            public void perform(QueryBuilder queryBuilder) {
-                doDeleteByQuery(queryBuilder);
-            }
-        };
-        testee = new ElasticSearchIndexer(clientProvider.get(), deleteByQueryPerformer);
-    }
-    
-    @Test
-    public void indexMessageShouldWork() throws Exception {
-        String messageId = "1";
-        String content = "{\"message\": \"trying out Elasticsearch\"}";
-        
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchQuery("message", "trying"))
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-    
-    @Test(expected=IllegalArgumentException.class)
-    public void indexMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
-        testee.indexMessage("1", null);
-    }
-    
-    @Test
-    public void updateMessages() throws Exception {
-        String messageId = "1";
-        String content = "{\"message\": \"trying out Elasticsearch\",\"field\":\"Should be unchanged\"}";
-
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation(messageId, "{\"message\": \"mastering out Elasticsearch\"}")));
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setQuery(QueryBuilders.matchQuery("message", "mastering"))
-                .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setQuery(QueryBuilders.matchQuery("field", "unchanged"))
-                .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenJsonIsNull() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("1", null)));
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenIdIsNull() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation(null, "{\"message\": \"mastering out Elasticsearch\"}")));
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenJsonIsEmpty() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("1", "")));
-    }
-
-    @Test(expected=IllegalArgumentException.class)
-    public void updateMessageShouldThrowWhenIdIsEmpty() throws InterruptedException {
-        testee.updateMessages(Lists.newArrayList(new ElasticSearchIndexer.UpdatedRepresentation("", "{\"message\": \"mastering out Elasticsearch\"}")));
-    }
-
-    @Test
-    public void deleteByQueryShouldWorkOnSingleMessage() throws Exception {
-        String messageId = "1:2";
-        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
-
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        testee.deleteAllMatchingQuery(termQuery(JsonMessageConstants.MAILBOX_ID, "1"));
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
-        }
-    }
-
-    @Test
-    public void deleteByQueryShouldWorkWhenMultipleMessages() throws Exception {
-        String messageId = "1:1";
-        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
-        
-        testee.indexMessage(messageId, content);
-        
-        String messageId2 = "1:2";
-        String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}";
-        
-        testee.indexMessage(messageId2, content2);
-        
-        String messageId3 = "2:3";
-        String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}";
-        
-        testee.indexMessage(messageId3, content3);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.deleteAllMatchingQuery(termQuery(JsonMessageConstants.MAILBOX_ID, "1"));
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-    
-    @Test
-    public void deleteMessage() throws Exception {
-        String messageId = "1:2";
-        String content = "{\"message\": \"trying out Elasticsearch\"}";
-
-        testee.indexMessage(messageId, content);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.deleteMessages(Lists.newArrayList(messageId));
-        embeddedElasticSearch.awaitForElasticSearch();
-        
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                    .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .setQuery(QueryBuilders.matchAllQuery())
-                    .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(0);
-        }
-    }
-
-    @Test
-    public void deleteShouldWorkWhenMultipleMessages() throws Exception {
-        String messageId = "1:1";
-        String content = "{\"message\": \"trying out Elasticsearch\", \"mailboxId\":\"1\"}";
-
-        testee.indexMessage(messageId, content);
-
-        String messageId2 = "1:2";
-        String content2 = "{\"message\": \"trying out Elasticsearch 2\", \"mailboxId\":\"1\"}";
-
-        testee.indexMessage(messageId2, content2);
-
-        String messageId3 = "2:3";
-        String content3 = "{\"message\": \"trying out Elasticsearch 3\", \"mailboxId\":\"2\"}";
-
-        testee.indexMessage(messageId3, content3);
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        testee.deleteMessages(Lists.newArrayList(messageId, messageId3));
-        embeddedElasticSearch.awaitForElasticSearch();
-
-        try (Client client = node.client()) {
-            SearchResponse searchResponse = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setQuery(QueryBuilders.matchAllQuery())
-                .get();
-            assertThat(searchResponse.getHits().getTotalHits()).isEqualTo(1);
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/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 fb73266..92b2331 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
@@ -22,6 +22,12 @@ package org.apache.james.mailbox.elasticsearch;
 import java.time.ZoneId;
 import java.util.concurrent.Executors;
 
+import org.apache.james.backends.es.DeleteByQueryPerformer;
+import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
@@ -29,7 +35,6 @@ import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxManager;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
@@ -52,7 +57,7 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
     private static final int SEARCH_SIZE = 1;
 
     private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder);
+    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder, MailboxElasticsearchConstants.MAILBOX_INDEX);
 
     @Rule
     public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
@@ -65,12 +70,24 @@ public class ElasticSearchIntegrationTest extends AbstractMessageSearchIndexTest
     @Override
     protected void initializeMailboxManager() throws Exception {
         Client client = NodeMappingFactory.applyMapping(
-            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get())
-        );
+            IndexCreationFactory.createIndex(
+                new TestingClientProvider(embeddedElasticSearch.getNode()).get(),
+                MailboxElasticsearchConstants.MAILBOX_INDEX),
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent());
+
         MailboxSessionMapperFactory mapperFactory = new InMemoryMailboxSessionMapperFactory();
         InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
         messageSearchIndex = new ElasticSearchListeningMessageSearchIndex(mapperFactory,
-            new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), BATCH_SIZE)),
+            new ElasticSearchIndexer(client,
+                new DeleteByQueryPerformer(client,
+                    Executors.newSingleThreadExecutor(),
+                    BATCH_SIZE,
+                    MailboxElasticsearchConstants.MAILBOX_INDEX,
+                    MailboxElasticsearchConstants.MESSAGE_TYPE),
+                MailboxElasticsearchConstants.MAILBOX_INDEX,
+                MailboxElasticsearchConstants.MESSAGE_TYPE),
             new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), SEARCH_SIZE, new InMemoryId.Factory(), messageIdFactory),
             new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES, MessageSearchIndex.IndexMessageId.Required));
         storeMailboxManager = new InMemoryMailboxManager(

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java
deleted file mode 100644
index 4f199ef..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/EmbeddedElasticSearch.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/****************************************************************
- * 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;
-
-import static com.jayway.awaitility.Awaitility.await;
-import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.util.function.Supplier;
-
-import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
-import org.elasticsearch.action.admin.indices.flush.FlushAction;
-import org.elasticsearch.action.admin.indices.flush.FlushRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.node.Node;
-import org.junit.rules.ExternalResource;
-import org.junit.rules.TemporaryFolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Throwables;
-import com.jayway.awaitility.Duration;
-
-public class EmbeddedElasticSearch extends ExternalResource {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(EmbeddedElasticSearch.class);
-
-    private final Supplier<Path> folder;
-    private Node node;
-
-    private static Path createTempDir(TemporaryFolder temporaryFolder) {
-        try {
-            return temporaryFolder.newFolder().toPath();
-        } catch (IOException e) {
-            throw Throwables.propagate(e);
-        }
-    }
-
-    public EmbeddedElasticSearch(TemporaryFolder temporaryFolder) {
-        this(() -> EmbeddedElasticSearch.createTempDir(temporaryFolder));
-    }
-
-    public EmbeddedElasticSearch(Path folder) {
-        this(() -> folder);
-    }
-
-    private EmbeddedElasticSearch(Supplier<Path> folder) {
-        this.folder = folder;
-    }
-
-    @Override
-    public void before() throws IOException {
-        node = nodeBuilder().local(true)
-            .settings(Settings.builder()
-                .put("path.home", folder.get().toAbsolutePath())
-                .build())
-            .node();
-        node.start();
-        awaitForElasticSearch();
-    }
-
-    @Override
-    public void after() {
-        awaitForElasticSearch();
-        try (Client client = node.client()) {
-            client.admin()
-                .indices()
-                .delete(new DeleteIndexRequest(ElasticSearchIndexer.MAILBOX_INDEX))
-                .actionGet();
-        } catch (Exception e) {
-            LOGGER.warn("Error while closing ES connection", e);
-        }
-        node.close();
-    }
-
-    public Node getNode() {
-        return node;
-    }
-
-    /**
-     * Sometimes, tests are too fast.
-     * This method ensure that ElasticSearch service is up and indices are updated
-     */
-    public void awaitForElasticSearch() {
-        await().atMost(Duration.TEN_SECONDS).until(this::flush);
-    }
-
-    private boolean flush() {
-        try (Client client = node.client()) {
-            new FlushRequestBuilder(client, FlushAction.INSTANCE).setForce(true).get();
-            return true;
-        } catch (Exception e) {
-            return false;
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
index 4a9fc33..a9ea500 100644
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
+++ b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/events/ElasticSearchListeningMailboxMessageSearchIndexTest.java
@@ -31,10 +31,10 @@ import java.util.List;
 
 import javax.mail.Flags;
 
+import org.apache.james.backends.es.ElasticSearchIndexer;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.MailboxSession.User;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
 import org.apache.james.mailbox.model.TestId;

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java
deleted file mode 100644
index 75313a1..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/search/ScrollIterableTest.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/****************************************************************
- * 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.search;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
-import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.apache.james.mailbox.elasticsearch.ElasticSearchIndexer;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
-import org.apache.james.mailbox.elasticsearch.IndexCreationFactory;
-import org.apache.james.mailbox.elasticsearch.NodeMappingFactory;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
-import org.elasticsearch.action.search.SearchRequestBuilder;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.common.unit.TimeValue;
-import org.elasticsearch.common.xcontent.XContentBuilder;
-import org.elasticsearch.search.SearchHit;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TemporaryFolder;
-
-public class ScrollIterableTest {
-
-    public static final TimeValue TIMEOUT = new TimeValue(6000);
-    public static final int SIZE = 2;
-    public static final String MESSAGE = "message";
-
-    private TemporaryFolder temporaryFolder = new TemporaryFolder();
-    private EmbeddedElasticSearch embeddedElasticSearch= new EmbeddedElasticSearch(temporaryFolder);
-
-    @Rule
-    public RuleChain ruleChain = RuleChain.outerRule(temporaryFolder).around(embeddedElasticSearch);
-
-    private ClientProvider clientProvider;
-
-    @Before
-    public void setUp() throws Exception {
-        clientProvider = new TestingClientProvider(embeddedElasticSearch.getNode());
-        IndexCreationFactory.createIndex(clientProvider.get());
-        embeddedElasticSearch.awaitForElasticSearch();
-        NodeMappingFactory.applyMapping(clientProvider.get(), getMappingsSources());
-    }
-
-    private XContentBuilder getMappingsSources() throws IOException {
-        return jsonBuilder()
-            .startObject()
-                .startObject(ElasticSearchIndexer.MESSAGE_TYPE)
-                    .startObject(NodeMappingFactory.PROPERTIES)
-                        .startObject(MESSAGE)
-                            .field(NodeMappingFactory.TYPE, NodeMappingFactory.STRING)
-                        .endObject()
-                    .endObject()
-                .endObject()
-            .endObject();
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenEmpty() {
-        try (Client client = clientProvider.get()) {
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(new ScrollIterable(client, searchRequestBuilder)).isEmpty();
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenOneElement() {
-        try (Client client = clientProvider.get()) {
-            String id = "1";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            embeddedElasticSearch.awaitForElasticSearch();
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id);
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenSizeElement() {
-        try (Client client = clientProvider.get()) {
-            String id1 = "1";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id1)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id2 = "2";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id2)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            embeddedElasticSearch.awaitForElasticSearch();
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2);
-        }
-    }
-
-    @Test
-    public void scrollIterableShouldWorkWhenMoreThanSizeElement() {
-        try (Client client = clientProvider.get()) {
-            String id1 = "1";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id1)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id2 = "2";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id2)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            String id3 = "3";
-            client.prepareIndex(ElasticSearchIndexer.MAILBOX_INDEX, ElasticSearchIndexer.MESSAGE_TYPE, id3)
-                .setSource(MESSAGE, "Sample message")
-                .execute();
-
-            embeddedElasticSearch.awaitForElasticSearch();
-
-            SearchRequestBuilder searchRequestBuilder = client.prepareSearch(ElasticSearchIndexer.MAILBOX_INDEX)
-                .setTypes(ElasticSearchIndexer.MESSAGE_TYPE)
-                .setScroll(TIMEOUT)
-                .setQuery(matchAllQuery())
-                .setSize(SIZE);
-            assertThat(convertToIdList(new ScrollIterable(client, searchRequestBuilder))).containsOnly(id1, id2, id3);
-        }
-    }
-
-    private List<String> convertToIdList(ScrollIterable scrollIterable) {
-        return scrollIterable.stream()
-            .flatMap(searchResponse -> Arrays.asList(searchResponse.getHits().getHits()).stream())
-            .map(SearchHit::getId)
-            .collect(Collectors.toList());
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java b/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java
deleted file mode 100644
index 9fdaaa7..0000000
--- a/mailbox/elasticsearch/src/test/java/org/apache/james/mailbox/elasticsearch/utils/TestingClientProvider.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/****************************************************************
- * 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.utils;
-
-import org.apache.james.mailbox.elasticsearch.ClientProvider;
-import org.elasticsearch.client.Client;
-import org.elasticsearch.node.Node;
-
-public class TestingClientProvider implements ClientProvider {
-
-    private final Node node;
-
-    public TestingClientProvider(Node node) {
-        this.node = node;
-    }
-    
-    @Override
-    public Client get() {
-        return node.client();
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mailbox/pom.xml
----------------------------------------------------------------------
diff --git a/mailbox/pom.xml b/mailbox/pom.xml
index e838610..ab42cf4 100644
--- a/mailbox/pom.xml
+++ b/mailbox/pom.xml
@@ -298,6 +298,25 @@
                 <version>${project.version}</version>
                 <type>test-jar</type>
             </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
 
             <!--
                 START Logging

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/imap-mailbox/elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/elasticsearch/pom.xml b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
index bc9ce66..0a4e36f 100644
--- a/mpt/impl/imap-mailbox/elasticsearch/pom.xml
+++ b/mpt/impl/imap-mailbox/elasticsearch/pom.xml
@@ -128,16 +128,28 @@
             <dependencies>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-api</artifactId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <version>${project.version}</version>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <version>${project.version}</version>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <version>3.0.0-beta6-SNAPSHOT</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-mailbox-api</artifactId>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
                     <artifactId>apache-james-mailbox-elasticsearch</artifactId>
-                    <type>test-jar</type>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/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 e6a09a7..6cac0a3 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
@@ -25,6 +25,12 @@ import java.time.ZoneId;
 import java.util.concurrent.Executors;
 
 import org.apache.commons.io.FileUtils;
+import org.apache.james.backends.es.DeleteByQueryPerformer;
+import org.apache.james.backends.es.ElasticSearchIndexer;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
+import org.apache.james.backends.es.utils.TestingClientProvider;
 import org.apache.james.imap.api.process.ImapProcessor;
 import org.apache.james.imap.encode.main.DefaultImapEncoderFactory;
 import org.apache.james.imap.main.DefaultImapDecoderFactory;
@@ -33,18 +39,14 @@ import org.apache.james.mailbox.acl.GroupMembershipResolver;
 import org.apache.james.mailbox.acl.MailboxACLResolver;
 import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
 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.MailboxElasticsearchConstants;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
 import org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJson;
 import org.apache.james.mailbox.elasticsearch.query.CriterionConverter;
 import org.apache.james.mailbox.elasticsearch.query.QueryConverter;
 import org.apache.james.mailbox.elasticsearch.search.ElasticSearchSearcher;
-import org.apache.james.mailbox.elasticsearch.utils.TestingClientProvider;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.inmemory.InMemoryId;
 import org.apache.james.mailbox.inmemory.InMemoryMailboxSessionMapperFactory;
@@ -84,7 +86,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
     @Override
     public void beforeTest() throws Exception {
         this.tempDirectory = Files.createTempDirectory("elasticsearch");
-        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory);
+        this.embeddedElasticSearch = new EmbeddedElasticSearch(tempDirectory, MailboxElasticsearchConstants.MAILBOX_INDEX);
         embeddedElasticSearch.before();
         initFields();
     }
@@ -102,7 +104,10 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
 
     private void initFields() {
         Client client = NodeMappingFactory.applyMapping(
-            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get())
+            IndexCreationFactory.createIndex(new TestingClientProvider(embeddedElasticSearch.getNode()).get(), MailboxElasticsearchConstants.MAILBOX_INDEX),
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent()
         );
 
         userManager = new FakeAuthenticator();
@@ -111,7 +116,7 @@ public class ElasticSearchHostSystem extends JamesImapHostSystem {
 
         ElasticSearchListeningMessageSearchIndex searchIndex = new ElasticSearchListeningMessageSearchIndex(
             factory,
-            new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor())),
+            new ElasticSearchIndexer(client, new DeleteByQueryPerformer(client, Executors.newSingleThreadExecutor(), MailboxElasticsearchConstants.MAILBOX_INDEX, MailboxElasticsearchConstants.MESSAGE_TYPE), MailboxElasticsearchConstants.MAILBOX_INDEX, MailboxElasticsearchConstants.MESSAGE_TYPE),
             new ElasticSearchSearcher(client, new QueryConverter(new CriterionConverter()), new InMemoryId.Factory(), messageIdFactory),
             new MessageToElasticSearchJson(new DefaultTextExtractor(), ZoneId.systemDefault(), IndexAttachments.YES, MessageSearchIndex.IndexMessageId.Required));
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/smtp/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/pom.xml b/mpt/impl/smtp/cassandra/pom.xml
index 051bd9e..2ac1e1c 100644
--- a/mpt/impl/smtp/cassandra/pom.xml
+++ b/mpt/impl/smtp/cassandra/pom.xml
@@ -160,9 +160,9 @@
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-elasticsearch</artifactId>
-                    <scope>test</scope>
+                    <artifactId>apache-james-backends-es</artifactId>
                     <type>test-jar</type>
+                    <scope>test</scope>
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
@@ -255,7 +255,7 @@
                 </dependency>
                 <dependency>
                     <groupId>org.apache.james</groupId>
-                    <artifactId>apache-james-mailbox-elasticsearch</artifactId>
+                    <artifactId>apache-james-backends-es</artifactId>
                     <scope>test</scope>
                     <type>test-jar</type>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
index f90bca9..c7320f3 100644
--- a/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
+++ b/mpt/impl/smtp/cassandra/src/test/java/org/apache/james/mpt/smtp/host/CassandraJamesSmtpHostSystem.java
@@ -24,8 +24,9 @@ import java.util.Iterator;
 import org.apache.james.CassandraJamesServerMain;
 import org.apache.james.GuiceJamesServerImpl;
 import org.apache.james.backends.cassandra.EmbeddedCassandra;
+import org.apache.james.backends.es.EmbeddedElasticSearch;
 import org.apache.james.dnsservice.api.DNSService;
-import org.apache.james.mailbox.elasticsearch.EmbeddedElasticSearch;
+import org.apache.james.mailbox.elasticsearch.MailboxElasticsearchConstants;
 import org.apache.james.modules.CassandraJmapServerModule;
 import org.apache.james.mpt.monitor.SystemLoggingMonitor;
 import org.apache.james.mpt.session.ExternalSessionFactory;
@@ -86,7 +87,7 @@ public class CassandraJamesSmtpHostSystem extends ExternalSessionFactory impleme
         inMemoryDNSService = new InMemoryDNSService();
         folder = new TemporaryFolder();
         folder.create();
-        embeddedElasticSearch = new EmbeddedElasticSearch(folder.getRoot().toPath());
+        embeddedElasticSearch = new EmbeddedElasticSearch(folder.getRoot().toPath(), MailboxElasticsearchConstants.MAILBOX_INDEX);
         embeddedElasticSearch.before();
         embeddedCassandra = EmbeddedCassandra.createStartServer();
         jamesServer = createJamesServer();

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/mpt/pom.xml
----------------------------------------------------------------------
diff --git a/mpt/pom.xml b/mpt/pom.xml
index 4b5a519..aa4edb4 100644
--- a/mpt/pom.xml
+++ b/mpt/pom.xml
@@ -169,6 +169,13 @@
             </dependency>
             <dependency>
                 <groupId>org.apache.james</groupId>
+                <artifactId>apache-james-backends-es</artifactId>
+                <type>test-jar</type>
+                <scope>test</scope>
+                <version>${project.version}</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.james</groupId>
                 <artifactId>apache-james-backends-jpa</artifactId>
                 <type>test-jar</type>
                 <version>${project.version}</version>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/server/container/guice/cassandra-guice/pom.xml
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml
index 522d6bc..70fec90 100644
--- a/server/container/guice/cassandra-guice/pom.xml
+++ b/server/container/guice/cassandra-guice/pom.xml
@@ -198,6 +198,12 @@
                     <scope>test</scope>
                 </dependency>
                 <dependency>
+                    <groupId>org.apache.james</groupId>
+                    <artifactId>apache-james-backends-es</artifactId>
+                    <type>test-jar</type>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
                     <groupId>${project.groupId}</groupId>
                     <artifactId>apache-james-mailbox-cassandra</artifactId>
                 </dependency>

http://git-wip-us.apache.org/repos/asf/james-project/blob/1688bc6f/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 eb979a2..8d79af2 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
@@ -26,12 +26,14 @@ import javax.inject.Singleton;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.james.backends.es.ClientProvider;
+import org.apache.james.backends.es.ClientProviderImpl;
+import org.apache.james.backends.es.IndexCreationFactory;
+import org.apache.james.backends.es.NodeMappingFactory;
 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.MailboxElasticsearchConstants;
+import org.apache.james.mailbox.elasticsearch.MailboxMappingFactory;
 import org.apache.james.mailbox.elasticsearch.events.ElasticSearchListeningMessageSearchIndex;
 import org.apache.james.mailbox.extractor.TextExtractor;
 import org.apache.james.mailbox.store.search.ListeningMessageSearchIndex;
@@ -47,12 +49,12 @@ import com.nurkiewicz.asyncretry.AsyncRetryExecutor;
 
 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;
     public static final String ES_CONFIG_FILE = FileSystem.FILE_PROTOCOL_AND_CONF + "elasticsearch.properties";
     public static final String ELASTICSEARCH_MASTER_HOST = "elasticsearch.masterHost";
     public static final String ELASTICSEARCH_PORT = "elasticsearch.port";
+    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() {
@@ -74,9 +76,13 @@ public class ElasticSearchMailboxModule extends AbstractModule {
         Client client = getRetryer(executor, propertiesReader)
                 .getWithRetry(ctx -> clientProvider.get()).get();
         IndexCreationFactory.createIndex(client,
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
             propertiesReader.getInt("elasticsearch.nb.shards"),
             propertiesReader.getInt("elasticsearch.nb.replica"));
-        NodeMappingFactory.applyMapping(client);
+        NodeMappingFactory.applyMapping(client,
+            MailboxElasticsearchConstants.MAILBOX_INDEX,
+            MailboxElasticsearchConstants.MESSAGE_TYPE,
+            MailboxMappingFactory.getMappingContent());
         return client;
     }
 


---------------------------------------------------------------------
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