#741 - ENH: Add DocumentStore indexSettings() method ... for setting ElasticSearch refresh_interval

This commit is contained in:
Robin Bygrave
2016-06-17 22:21:22 +12:00
parent f47cd7e7c2
commit f144b53651
2 changed files with 40 additions and 0 deletions
@@ -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.
* <p>
* For example, this can be used be used to set elasticSearch refresh_interval
* on an index before a bulk update.
* </p>
* <pre>{@code
*
* // refresh_interval -1 ... disable refresh while bulk loading
*
* Map<String,Object> settings = new LinkedHashMap<>();
* settings.put("refresh_interval", "-1");
*
* documentStore.indexSettings("product", settings);
*
* }</pre>
*
* <pre>{@code
*
* // refresh_interval 1s ... restore after bulk loading
*
* Map<String,Object> settings = new LinkedHashMap<>();
* settings.put("refresh_interval", "1s");
*
* documentStore.indexSettings("product", settings);
*
* }</pre>
*
* @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<String, Object> settings);
/**
* Copy the index to a new index.
* <p>
@@ -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<String, Object> settings) {
throw implementationNotInClassPath();
}
@Override
public void dropIndex(String newIndex) {
throw implementationNotInClassPath();