public class ElasticsearchAdminServiceImpl extends Object implements ElasticsearchAdminService
ElasticsearchAdminService| Modifier and Type | Field and Description |
|---|---|
protected org.springframework.core.io.Resource |
authoringMapping
Index mapping file for authoring indices
|
static String |
DEFAULT_INDEX_NAME_SUFFIX |
protected Map<String,String> |
defaultSettings
The default settings used when creating indices
|
protected org.elasticsearch.client.RestHighLevelClient |
elasticsearchClient
The Elasticsearch client
|
protected String |
indexNameSuffix
The suffix to add to all index names during creation
|
protected org.springframework.core.io.Resource |
previewMapping
Index mapping file for preview indices
|
| Constructor and Description |
|---|
ElasticsearchAdminServiceImpl(org.springframework.core.io.Resource authoringMapping,
org.springframework.core.io.Resource previewMapping,
org.elasticsearch.client.RestHighLevelClient elasticsearchClient,
Map<String,String> defaultSettings) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
createIndex(String aliasName,
boolean isAuthoring)
Creates an index
|
void |
deleteIndexes(String aliasName)
Deletes all indexes assigned to the given alias
|
protected void |
doCreateIndex(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
String indexSuffix,
boolean isAuthoring,
boolean createAlias,
Map<String,String> settings)
Performs the index creation without any alias association
|
protected void |
doCreateIndexAndAlias(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
boolean isAuthoring)
Performs the index creation using the given Elasticsearch client
|
protected void |
doCreateIndexAndAlias(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
String indexSuffix,
boolean isAuthoring)
Performs the index creation using the given Elasticsearch client
|
protected void |
doDeleteIndex(org.elasticsearch.client.RestHighLevelClient client,
String indexName) |
protected void |
doDeleteIndexes(org.elasticsearch.client.RestHighLevelClient client,
String aliasName)
Performs the index delete using the given Elasticsearch client
|
protected Optional<String> |
doGetIndexName(org.elasticsearch.client.RestHighLevelClient client,
String aliasName) |
protected Map<String,String> |
doGetIndexSettings(org.elasticsearch.client.RestHighLevelClient client,
String indexName) |
protected void |
doRecreateIndex(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
boolean isAuthoring)
Performs all operations for recreating an index using the given Elasticsearch client
|
protected void |
doReindex(org.elasticsearch.client.RestHighLevelClient client,
String sourceIndex,
String destinationIndex) |
protected void |
doSwap(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
String existingIndexName,
String newIndexName) |
protected void |
doWaitUntilReady(org.elasticsearch.client.RestHighLevelClient client) |
protected boolean |
exists(org.elasticsearch.client.RestHighLevelClient client,
String indexName)
Checks if a given index already exists in Elasticsearch
|
void |
recreateIndex(String aliasName,
boolean isAuthoring)
Recreates an existing index
|
void |
setIndexNameSuffix(String indexNameSuffix) |
void |
waitUntilReady()
Checks if the Elasticsearch cluster is ready to receive requests
|
public static final String DEFAULT_INDEX_NAME_SUFFIX
protected String indexNameSuffix
protected org.springframework.core.io.Resource authoringMapping
protected org.springframework.core.io.Resource previewMapping
protected org.elasticsearch.client.RestHighLevelClient elasticsearchClient
public void setIndexNameSuffix(String indexNameSuffix)
protected boolean exists(org.elasticsearch.client.RestHighLevelClient client,
String indexName)
client - the elasticsearch clientindexName - the index namepublic void createIndex(String aliasName, boolean isAuthoring) throws ElasticsearchException
createIndex in interface ElasticsearchAdminServicealiasName - the name of the aliasisAuthoring - indicates if the index is for authoringElasticsearchException - if there is any error during the operationprotected void doCreateIndexAndAlias(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
boolean isAuthoring)
protected void doCreateIndexAndAlias(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
String indexSuffix,
boolean isAuthoring)
protected void doCreateIndex(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
String indexSuffix,
boolean isAuthoring,
boolean createAlias,
Map<String,String> settings)
public void deleteIndexes(String aliasName) throws ElasticsearchException
deleteIndexes in interface ElasticsearchAdminServicealiasName - the name of the aliasElasticsearchException - if there is any error during the operationprotected void doDeleteIndexes(org.elasticsearch.client.RestHighLevelClient client,
String aliasName)
public void recreateIndex(String aliasName, boolean isAuthoring) throws ElasticsearchException
recreateIndex in interface ElasticsearchAdminServicealiasName - the name of the aliasisAuthoring - indicates if the index is for authoringElasticsearchException - if there is any error during the operationprotected void doRecreateIndex(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
boolean isAuthoring)
protected Optional<String> doGetIndexName(org.elasticsearch.client.RestHighLevelClient client, String aliasName) throws IOException
IOExceptionprotected Map<String,String> doGetIndexSettings(org.elasticsearch.client.RestHighLevelClient client, String indexName) throws IOException
IOExceptionprotected void doReindex(org.elasticsearch.client.RestHighLevelClient client,
String sourceIndex,
String destinationIndex)
throws IOException
IOExceptionprotected void doSwap(org.elasticsearch.client.RestHighLevelClient client,
String aliasName,
String existingIndexName,
String newIndexName)
throws IOException
IOExceptionprotected void doDeleteIndex(org.elasticsearch.client.RestHighLevelClient client,
String indexName)
throws IOException
IOExceptionpublic void waitUntilReady()
ElasticsearchAdminServicewaitUntilReady in interface ElasticsearchAdminServiceprotected void doWaitUntilReady(org.elasticsearch.client.RestHighLevelClient client)
public void close()
throws Exception
close in interface AutoCloseableExceptionCopyright © 2020 CrafterCMS. All rights reserved.