@Service @Validated public class AdminService extends Object
Constructor and Description |
---|
AdminService(ESClient esClient,
org.springframework.data.elasticsearch.core.ElasticsearchOperations elasticsearchOperations) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkIsUp()
Checks if connection to Elasticsearch cluster is up.
|
boolean |
closeIndex(String indexName)
Closes an Elasticsearch index.
|
boolean |
createIndex(Class clazz)
Creating an Elasticsearch index from given class.
|
boolean |
createIndex(CreateIndexRequest createIndexRequest)
Creates an Elasticsearch index from given index request.
|
boolean |
deleteIndex(Class clazz)
Deletes an Elasticsearch index from given class.
|
boolean |
deleteIndex(String indexName)
Deletes an Elasticsearch index by given name.
|
boolean |
documentExists(ESDocumentIdentifierDTO dto)
Checks if a document exists.
|
boolean |
documentExists(String indexName,
String typeName,
String id)
Checks if a document exists.
|
boolean |
indexExists(Class clazz)
Checks if an Elasticsearch index from given class exists.
|
boolean |
indexExists(String indexName)
Checks if an Elasticsearch index with the given name, exists.
|
protected boolean |
isClassValid(Class clazz)
Checks if the provided class is annotated with @
Document |
boolean |
openIndex(String indexName)
Opens an Elasticsearch index.
|
boolean |
updateIndexSettings(String indexName,
Map<String,String> settings,
boolean preserveExisting)
Updates the settings of given Elasticsearch index.
|
boolean |
updateTypeMapping(UpdateMappingRequest updateRequest)
Updates the type mapping of an Elasticsearch index.
|
@Autowired public AdminService(ESClient esClient, org.springframework.data.elasticsearch.core.ElasticsearchOperations elasticsearchOperations)
public boolean createIndex(CreateIndexRequest createIndexRequest)
createIndexRequest
- object containing the index informationpublic boolean createIndex(Class clazz)
clazz
- a class annotated with Elasticsearch annotationspublic boolean deleteIndex(String indexName)
indexName
- the name of the index to deletepublic boolean deleteIndex(Class clazz)
clazz
- a class annotated with Elasticsearch annotationspublic boolean indexExists(String indexName)
indexName
- the name of the indexpublic boolean indexExists(Class clazz)
clazz
- the classpublic boolean documentExists(String indexName, String typeName, String id)
indexName
- the name of the index that the document is part oftypeName
- the name of the index type that the document is part ofid
- the id of the documentpublic boolean documentExists(ESDocumentIdentifierDTO dto)
dto
- holds all the information needed to search for the document (index name, index id,
document id)public boolean updateTypeMapping(UpdateMappingRequest updateRequest)
updateRequest
- holds all information needed to update the mappingpublic boolean updateIndexSettings(String indexName, Map<String,String> settings, boolean preserveExisting)
indexName
- the name of the index to updatesettings
- the updated settingspreserveExisting
- a flag to define whether the existing settings should be preserved or
overwritten@Async public boolean closeIndex(String indexName)
indexName
- the name of the index to closepublic boolean openIndex(String indexName)
indexName
- the name of the index to openpublic boolean checkIsUp()
protected boolean isClassValid(Class clazz)
Document
clazz
- the classCopyright © 2020. All rights reserved.