DATAES-88 - add method createIndex(Class<T> clazz, Object settings)
This commit is contained in:
@@ -61,6 +61,14 @@ public interface ElasticsearchOperations {
|
||||
*/
|
||||
boolean createIndex(String indexName, Object settings);
|
||||
|
||||
/**
|
||||
* Create an index for given class and Settings
|
||||
*
|
||||
* @param clazz
|
||||
* @param settings
|
||||
*/
|
||||
<T> boolean createIndex(Class<T> clazz, Object settings);
|
||||
|
||||
/**
|
||||
* Create mapping for a class
|
||||
*
|
||||
|
||||
@@ -643,6 +643,11 @@ public class ElasticsearchTemplate implements ElasticsearchOperations {
|
||||
return createIndexRequestBuilder.execute().actionGet().isAcknowledged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean createIndex(Class<T> clazz, Object settings) {
|
||||
return createIndex(getPersistentEntityFor(clazz).getIndexName(), settings);
|
||||
}
|
||||
|
||||
private <T> Map getDefaultSettings(ElasticsearchPersistentEntity<T> persistentEntity) {
|
||||
return new MapBuilder<String, String>().put("index.number_of_shards", String.valueOf(persistentEntity.getShards()))
|
||||
.put("index.number_of_replicas", String.valueOf(persistentEntity.getReplicas()))
|
||||
|
||||
Reference in New Issue
Block a user