diff --git a/src/main/java/com/avaje/ebean/DocumentStore.java b/src/main/java/com/avaje/ebean/DocumentStore.java index c74d5d76e..22b30f953 100644 --- a/src/main/java/com/avaje/ebean/DocumentStore.java +++ b/src/main/java/com/avaje/ebean/DocumentStore.java @@ -5,6 +5,7 @@ import org.jetbrains.annotations.Nullable; import java.io.IOException; import java.util.List; +import java.util.Map; /** * Document storage operations. @@ -205,6 +206,39 @@ public interface DocumentStore { */ void createIndex(String indexName, String alias); + /** + * Modify the settings on an index. + *

+ * For example, this can be used be used to set elasticSearch refresh_interval + * on an index before a bulk update. + *

+ *
{@code
+   *
+   *   // refresh_interval -1 ... disable refresh while bulk loading
+   *
+   *   Map settings = new LinkedHashMap<>();
+   *   settings.put("refresh_interval", "-1");
+   *
+   *   documentStore.indexSettings("product", settings);
+   *
+   * }
+ * + *
{@code
+   *
+   *   // refresh_interval 1s ... restore after bulk loading
+   *
+   *   Map settings = new LinkedHashMap<>();
+   *   settings.put("refresh_interval", "1s");
+   *
+   *   documentStore.indexSettings("product", settings);
+   *
+   * }
+ * + * @param indexName the name of the index to update settings on + * @param settings the settings to set on the index + */ + void indexSettings(String indexName, Map settings); + /** * Copy the index to a new index. *

diff --git a/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStore.java b/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStore.java index fc09931c0..ce49b9dc9 100644 --- a/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStore.java +++ b/src/main/java/com/avaje/ebeanservice/docstore/none/NoneDocStore.java @@ -10,6 +10,7 @@ import com.avaje.ebeanservice.docstore.api.DocQueryRequest; import java.io.IOException; import java.util.List; +import java.util.Map; /** * DocumentStore that barfs it is used. @@ -20,6 +21,11 @@ public class NoneDocStore implements DocumentStore { throw new IllegalStateException("DocStore implementation not included in the classPath. You need to add the maven dependency for avaje-ebeanorm-elastic"); } + @Override + public void indexSettings(String indexName, Map settings) { + throw implementationNotInClassPath(); + } + @Override public void dropIndex(String newIndex) { throw implementationNotInClassPath();