Class OpenSearchAdminServiceImpl
java.lang.Object
org.craftercms.search.opensearch.impl.OpenSearchAdminServiceImpl
- All Implemented Interfaces:
AutoCloseable,OpenSearchAdminService
- Direct Known Subclasses:
MultiOpenSearchAdminServiceImpl
Default implementation of
OpenSearchAdminService- Since:
- 3.1.0
- Author:
- joseross
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.springframework.core.io.ResourceIndex mapping file for authoring indicesprotected final StringRegex used to determine if an index is for authoringstatic final Stringstatic final intThe default settings used when creating indicesstatic final Stringstatic final StringThe settings to ignore on duplicate indexprotected StringThe suffix to add to all index names during creationThe map of locale codes to OpenSearch languagesprotected final org.opensearch.client.RestHighLevelClientThe OpenSearch clientprotected final org.springframework.core.io.ResourceIndex mapping file for preview indices -
Constructor Summary
ConstructorsConstructorDescriptionOpenSearchAdminServiceImpl(org.springframework.core.io.Resource authoringMapping, org.springframework.core.io.Resource previewMapping, String authoringNamePattern, Map<String, String> localeMapping, Map<String, String> defaultSettings, Set<String> ignoredSettings, org.opensearch.client.RestHighLevelClient openSearchClient) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidcreateIndex(String aliasName) Creates an indexvoidcreateIndex(String aliasName, Locale locale) Creates an index for the given localevoiddeleteIndexes(String aliasName) Deletes all indexes assigned to the given aliasprotected voiddoCreateIndex(org.opensearch.client.RestHighLevelClient client, String aliasName, String indexSuffix, Locale locale, boolean createAlias, Map<String, String> settings) Performs the index creation using the given OpenSearch clientprotected voiddoCreateIndex(org.opensearch.client.RestHighLevelClient client, String aliasName, Locale locale) Performs the index creation using the given OpenSearch clientprotected voiddoDeleteIndex(org.opensearch.client.RestHighLevelClient client, String indexName) protected voiddoDeleteIndexes(org.opensearch.client.RestHighLevelClient client, String aliasName) Performs the index delete using the given OpenSearch clientprotected voiddoDuplicateIndex(org.opensearch.client.RestHighLevelClient client, String srcAliasName, String destAliasName) doGetIndexes(org.opensearch.client.RestHighLevelClient client, String aliasName) doGetIndexSettings(org.opensearch.client.RestHighLevelClient client, String indexAlias) protected booleandoIndexExist(org.opensearch.client.RestHighLevelClient client, String indexName) protected voiddoRecreateIndex(org.opensearch.client.RestHighLevelClient client, String aliasName) Performs all operations for recreating an index using the given OpenSearch clientprotected voiddoReindex(org.opensearch.client.RestHighLevelClient client, String sourceIndex, String destinationIndex) protected voiddoSwap(org.opensearch.client.RestHighLevelClient client, String aliasName, String existingIndexName, String newIndexName) protected voiddoWaitUntilReady(org.opensearch.client.RestHighLevelClient client) voidduplicateIndex(String srcAliasName, String destAliasName) Create a new index with the same settings and mappings as the source index, then reindex all data to the newly created index.booleanindexExists(String indexName) Indicates if an index exists for the given aliasvoidrecreateIndex(String aliasName) Recreates an existing indexvoidsetIndexNameSuffix(String indexNameSuffix) voidsetReindexSlices(int reindexSlices) voidsetReindexTimeoutSeconds(int reindexTimeoutSeconds) voidChecks if the OpenSearch cluster is ready to receive requests
-
Field Details
-
DEFAULT_WAIT_SLEEP_TIME_MILLIS
public static final int DEFAULT_WAIT_SLEEP_TIME_MILLIS- See Also:
-
DEFAULT_INDEX_NAME_SUFFIX
- See Also:
-
ES_STANDARD_ANALYZER
- See Also:
-
ES_KEY_DEFAULT_ANALYZER
- See Also:
-
indexNameSuffix
The suffix to add to all index names during creation -
authoringMapping
protected final org.springframework.core.io.Resource authoringMappingIndex mapping file for authoring indices -
previewMapping
protected final org.springframework.core.io.Resource previewMappingIndex mapping file for preview indices -
authoringNamePattern
Regex used to determine if an index is for authoring -
localeMapping
The map of locale codes to OpenSearch languages -
openSearchClient
protected final org.opensearch.client.RestHighLevelClient openSearchClientThe OpenSearch client -
defaultSettings
The default settings used when creating indices -
ignoredSettings
The settings to ignore on duplicate index
-
-
Constructor Details
-
OpenSearchAdminServiceImpl
@ConstructorProperties({"authoringMapping","previewMapping","authoringNamePattern","localeMapping","defaultSettings","ignoredSettings","openSearchClient"}) public OpenSearchAdminServiceImpl(org.springframework.core.io.Resource authoringMapping, org.springframework.core.io.Resource previewMapping, String authoringNamePattern, Map<String, String> localeMapping, Map<String, String> defaultSettings, Set<String> ignoredSettings, org.opensearch.client.RestHighLevelClient openSearchClient)
-
-
Method Details
-
setIndexNameSuffix
-
setReindexSlices
public void setReindexSlices(int reindexSlices) -
setReindexTimeoutSeconds
public void setReindexTimeoutSeconds(int reindexTimeoutSeconds) -
indexExists
Description copied from interface:OpenSearchAdminServiceIndicates if an index exists for the given alias- Specified by:
indexExistsin interfaceOpenSearchAdminService- Parameters:
indexName- the index alias- Returns:
- true if the index exists, false otherwise
-
doIndexExist
-
createIndex
Description copied from interface:OpenSearchAdminServiceCreates an index- Specified by:
createIndexin interfaceOpenSearchAdminService- Parameters:
aliasName- the name of the alias- Throws:
OpenSearchException- if there is any error during the operation
-
createIndex
Creates an index for the given locale- Specified by:
createIndexin interfaceOpenSearchAdminService- Parameters:
aliasName- the name of the aliaslocale- the locale for the index- Throws:
OpenSearchException
-
doCreateIndex
protected void doCreateIndex(org.opensearch.client.RestHighLevelClient client, String aliasName, Locale locale) Performs the index creation using the given OpenSearch client -
doCreateIndex
protected void doCreateIndex(org.opensearch.client.RestHighLevelClient client, String aliasName, String indexSuffix, Locale locale, boolean createAlias, Map<String, String> settings) Performs the index creation using the given OpenSearch client -
deleteIndexes
Deletes all indexes assigned to the given alias- Specified by:
deleteIndexesin interfaceOpenSearchAdminService- Parameters:
aliasName- the name of the alias- Throws:
OpenSearchException- if there is any error during the operation
-
doDeleteIndexes
Performs the index delete using the given OpenSearch client -
recreateIndex
Recreates an existing index- Specified by:
recreateIndexin interfaceOpenSearchAdminService- Parameters:
aliasName- the name of the alias- Throws:
OpenSearchException- if there is any error during the operation
-
doRecreateIndex
Performs all operations for recreating an index using the given OpenSearch client -
doGetIndexes
protected List<String> doGetIndexes(org.opensearch.client.RestHighLevelClient client, String aliasName) throws IOException - Throws:
IOException
-
doGetIndexSettings
protected Map<String,String> doGetIndexSettings(org.opensearch.client.RestHighLevelClient client, String indexAlias) throws IOException - Throws:
IOException
-
doReindex
protected void doReindex(org.opensearch.client.RestHighLevelClient client, String sourceIndex, String destinationIndex) throws IOException - Throws:
IOException
-
doSwap
protected void doSwap(org.opensearch.client.RestHighLevelClient client, String aliasName, String existingIndexName, String newIndexName) throws IOException - Throws:
IOException
-
doDeleteIndex
protected void doDeleteIndex(org.opensearch.client.RestHighLevelClient client, String indexName) throws IOException - Throws:
IOException
-
waitUntilReady
public void waitUntilReady()Description copied from interface:OpenSearchAdminServiceChecks if the OpenSearch cluster is ready to receive requests- Specified by:
waitUntilReadyin interfaceOpenSearchAdminService
-
duplicateIndex
Description copied from interface:OpenSearchAdminServiceCreate a new index with the same settings and mappings as the source index, then reindex all data to the newly created index.- Specified by:
duplicateIndexin interfaceOpenSearchAdminService- Parameters:
srcAliasName- the existing source indexdestAliasName- the new index to be created- Throws:
OpenSearchException- if there is any error during the operation
-
doDuplicateIndex
protected void doDuplicateIndex(org.opensearch.client.RestHighLevelClient client, String srcAliasName, String destAliasName) throws OpenSearchException - Throws:
OpenSearchException
-
doWaitUntilReady
protected void doWaitUntilReady(org.opensearch.client.RestHighLevelClient client) -
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-