public class IndexManagerImpl extends Object implements IndexManager, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.ApplicationContextAware, org.springframework.core.Ordered, org.springframework.beans.factory.InitializingBean
| Constructor and Description |
|---|
IndexManagerImpl(ElasticsearchClient elasticsearchClient,
String indexNamePrefix,
String projectName,
org.springframework.core.io.Resource[] mappingResources,
org.springframework.core.io.Resource[] mappingExtensionResources,
IndexTemplateComposer indexTemplateComposer,
com.fasterxml.jackson.databind.ObjectMapper objectMapper) |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected boolean |
compareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping,
com.fasterxml.jackson.databind.JsonNode updateMapping) |
protected void |
createCustomAlias(String alias,
String indexMapping) |
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> |
createCustomAliasesFromMappings(Map<String,com.fasterxml.jackson.databind.JsonNode> indexMetaData) |
protected void |
createCustomMappings() |
com.fasterxml.jackson.databind.JsonNode |
createIndexAndAlias(String alias,
String indexMapping) |
void |
createIndexesAndCustomAliasesFromMappings() |
Map<String,com.fasterxml.jackson.databind.JsonNode> |
createIndexesFromMappings()
Creates the indices for all known mappings
|
com.fasterxml.jackson.databind.JsonNode |
createIndexWithAlias(String indexName)
Creates an index.
|
String |
createIndexWithoutAlias(String indexName)
Similar to
IndexManager.createIndexWithAlias(String), but doesn't create an alias, only the index with the mapping. |
void |
deleteAliasAndRelatedIndices(String indexName)
Deletes the given index and all its aliases.
|
void |
deleteAllKnownIndices()
Deletes all indices registered in the system
|
void |
deleteIndex(String indexName)
Deletes the index with the given name.
|
protected String |
enhanceIndexName(String indexName) |
protected void |
enhanceMappingWithExtension(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations,
CustomIndexConfiguration customIndexConfiguration,
String indexName) |
protected void |
enhanceProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations,
CustomIndexConfiguration customIndexConfiguration,
String indexName) |
protected void |
enhanceVariableProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations,
CustomIndexConfiguration customIndexConfiguration,
String indexName) |
IndexMapping |
findIndexMapping(String indexName) |
List<IndexMapping> |
findMatchingCustomMappings(String indexName)
Returns a list of
IndexMapping(s) that are applicable for the provided index name. |
List<IndexMapping> |
findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
Returns a list of
IndexMapping instances that are applicable for the provided data. |
List<IndexMapping> |
findMatchingIndexMappings(String mappingType)
Returns a list of
IndexMapping(s) that are applicable for the provided mapping type. |
IndexMapping |
getCustomQueryMapping(String indexName,
String mappingName)
Get custom query mapping for given index if exists.
|
String |
getESIndexName(String indexName)
Returns the internal index name for the provided raw index name.
|
CustomIndexConfiguration |
getIndexConfiguration(String indexName)
Returns the mapping information for the given index.
|
String |
getIndexNamePrefix()
Returns the prefix that is added to all indices.
|
protected com.fasterxml.jackson.databind.node.ObjectNode |
getMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping,
com.fasterxml.jackson.databind.JsonNode updateMapping) |
int |
getOrder() |
boolean |
isKnownIndex(String index)
Returns whether the index is a known mapped index.
|
protected void |
logElasticsearchVersionInformation() |
void |
onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event) |
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> |
processMappingExtensionResources() |
protected void |
processMappingResources(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations) |
protected void |
processResources() |
IndexMapping |
recreateMapping(IndexMapping indexMapping)
Used to recreate mapping if
CustomIndexConfiguration changed. |
boolean |
reloadIndex(String indexName)
Reloads selected index
|
boolean |
reloadIndices()
Reloads all indexes
|
void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
void |
setOrder(int order) |
protected void |
updateExistingAliasMapping(IndexMapping customMapping) |
protected com.fasterxml.jackson.databind.JsonNode |
updateExistingMappingIfNeeded(String indexName,
IndexMapping indexMapping) |
protected void |
updateIndexAndMappingMetaData(String index,
com.fasterxml.jackson.databind.JsonNode metaData) |
protected void |
updateIndexMetaData(Map<String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData,
Map<String,List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData) |
protected boolean |
validateMappingExtensionJson(org.springframework.core.io.Resource mappingExtensionResource,
com.fasterxml.jackson.databind.JsonNode mappingExtensionJson) |
public static final int DEFAULT_ORDER
protected static final DateTimeFormatter INDEX_SUFFIX_FORMAT
protected static int MINIMAL_COMPATIBLE_ES_VERSION
protected static final String PROPERTIES_FIELD
protected static final String VARIABLE_PROPERTIES_FIELD
protected static final String VARIABLE_EXTRACTORS_FIELD
protected static final String FULL_TEXT_VARIABLES_FIELD
protected ElasticsearchClient elasticsearchClient
protected org.springframework.core.io.Resource[] mappingResources
protected org.springframework.core.io.Resource[] mappingExtensionResources
protected IndexTemplateComposer indexTemplateComposer
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper
protected String indexNamePrefix
protected Map<String,IndexMapping> indexMappings
protected Map<String,IndexMapping> customMappings
protected List<CustomIndexConfiguration> customConfigurations
protected Map<String,CustomIndexConfiguration> indexedDocumentTypes
protected org.springframework.context.ApplicationContext applicationContext
protected int order
public IndexManagerImpl(ElasticsearchClient elasticsearchClient, String indexNamePrefix, String projectName, org.springframework.core.io.Resource[] mappingResources, org.springframework.core.io.Resource[] mappingExtensionResources, IndexTemplateComposer indexTemplateComposer, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
public int getOrder()
getOrder in interface org.springframework.core.Orderedpublic void setOrder(int order)
protected void processResources()
protected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> processMappingExtensionResources()
protected boolean validateMappingExtensionJson(org.springframework.core.io.Resource mappingExtensionResource,
com.fasterxml.jackson.databind.JsonNode mappingExtensionJson)
protected void processMappingResources(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations)
protected void enhanceMappingWithExtension(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
protected void enhanceProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
protected void enhanceVariableProperties(Map<String,List<com.fasterxml.jackson.databind.JsonNode>> mappingExtensionConfigurations, CustomIndexConfiguration customIndexConfiguration, String indexName)
public String getIndexNamePrefix()
IndexManagergetIndexNamePrefix in interface IndexManagerpublic String getESIndexName(String indexName)
IndexManagergetESIndexName in interface IndexManagerindexName - the index name as being used in configuration, query DSL and APIpublic com.fasterxml.jackson.databind.JsonNode createIndexWithAlias(String indexName)
IndexManagercreateIndexWithAlias in interface IndexManagerpublic String createIndexWithoutAlias(String indexName)
IndexManagerIndexManager.createIndexWithAlias(String), but doesn't create an alias, only the index with the mapping.
Note that the index will still follow the aliasName-timeStamp pattern.
Note that the mapping will be looked up based on the name passed.createIndexWithoutAlias in interface IndexManagerpublic com.fasterxml.jackson.databind.JsonNode createIndexAndAlias(String alias, String indexMapping)
public IndexMapping getCustomQueryMapping(String indexName, String mappingName)
IndexManagergetCustomQueryMapping in interface IndexManagerpublic void deleteAliasAndRelatedIndices(String indexName)
IndexManagerdeleteAliasAndRelatedIndices in interface IndexManagerpublic void deleteIndex(String indexName)
IndexManagerdeleteIndex in interface IndexManagerpublic void deleteAllKnownIndices()
IndexManagerdeleteAllKnownIndices in interface IndexManagerpublic boolean isKnownIndex(String index)
IndexManagerisKnownIndex in interface IndexManagerpublic List<IndexMapping> findMatchingIndexMappings(com.fasterxml.jackson.databind.node.ObjectNode objectNode)
IndexManagerIndexMapping instances that are applicable for the provided data.findMatchingIndexMappings in interface IndexManagerpublic List<IndexMapping> findMatchingIndexMappings(String mappingType)
IndexManagerIndexMapping(s) that are applicable for the provided mapping type.findMatchingIndexMappings in interface IndexManagerpublic List<IndexMapping> findMatchingCustomMappings(String indexName)
IndexManagerIndexMapping(s) that are applicable for the provided index name.findMatchingCustomMappings in interface IndexManagerpublic IndexMapping findIndexMapping(String indexName)
findIndexMapping in interface IndexManagerpublic CustomIndexConfiguration getIndexConfiguration(String indexName)
IndexManagergetIndexConfiguration in interface IndexManagerpublic void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>public void createIndexesAndCustomAliasesFromMappings()
createIndexesAndCustomAliasesFromMappings in interface IndexManagerprotected void updateIndexMetaData(Map<String,com.fasterxml.jackson.databind.JsonNode> indicesMetaData, Map<String,List<com.fasterxml.jackson.databind.JsonNode>> aliasesMetaData)
protected void updateIndexAndMappingMetaData(String index, com.fasterxml.jackson.databind.JsonNode metaData)
protected void createCustomMappings()
public IndexMapping recreateMapping(IndexMapping indexMapping)
IndexManagerCustomIndexConfiguration changed.recreateMapping in interface IndexManagerprotected Map<String,List<com.fasterxml.jackson.databind.JsonNode>> createCustomAliasesFromMappings(Map<String,com.fasterxml.jackson.databind.JsonNode> indexMetaData)
protected void updateExistingAliasMapping(IndexMapping customMapping)
public Map<String,com.fasterxml.jackson.databind.JsonNode> createIndexesFromMappings()
IndexManagercreateIndexesFromMappings in interface IndexManagerprotected com.fasterxml.jackson.databind.JsonNode updateExistingMappingIfNeeded(String indexName, IndexMapping indexMapping)
protected boolean compareExtensionMetadata(com.fasterxml.jackson.databind.JsonNode currentMapping,
com.fasterxml.jackson.databind.JsonNode updateMapping)
protected com.fasterxml.jackson.databind.node.ObjectNode getMappingDelta(com.fasterxml.jackson.databind.JsonNode currentMapping,
com.fasterxml.jackson.databind.JsonNode updateMapping)
protected void logElasticsearchVersionInformation()
public boolean reloadIndices()
IndexManagerreloadIndices in interface IndexManagerpublic boolean reloadIndex(String indexName)
IndexManagerreloadIndex in interface IndexManagerpublic void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansException
setApplicationContext in interface org.springframework.context.ApplicationContextAwareorg.springframework.beans.BeansExceptionCopyright © 2019. All rights reserved.