Class ElasticsearchAccess
java.lang.Object
fr.gouv.vitam.common.database.server.elasticsearch.ElasticsearchAccess
- All Implemented Interfaces:
DatabaseConnection
- Direct Known Subclasses:
ElasticsearchAccessFunctionalAdmin,ElasticsearchAccessMetadata,LogbookElasticsearchAccess
Elasticsearch Access
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringstatic final intdefault limit scroll sizestatic final intdefault limit scroll timeoutprotected final List<ElasticsearchNode>static final StringKEYWORD to activate scroll -
Constructor Summary
ConstructorsConstructorDescriptionElasticsearchAccess(String clusterName, List<ElasticsearchNode> nodes) Create an ElasticSearch access -
Method Summary
Modifier and TypeMethodDescriptionbooleanCheck the connection of the databasevoidclearScroll(String scrollId) voidclose()Close the ElasticSearch connectionfinal voidcreateIndexAndAliasIfAliasNotExists(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings, String elasticsearchConfigurationFile) final ElasticsearchIndexAliascreateIndexWithoutAlias(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings, String elasticsearchConfigurationFile) voiddelete(ElasticsearchIndexAlias indexAlias, List<String> ids) final voiddeleteIndexByAliasForTesting(ElasticsearchIndexAlias indexAlias) final voiddeleteIndexForTesting(ElasticsearchIndexAlias indexAlias) final booleanexistsAlias(ElasticsearchIndexAlias indexAlias) final booleanfinal co.elastic.clients.elasticsearch.indices.GetAliasResponsegetAlias(ElasticsearchIndexAlias indexAlias) co.elastic.clients.elasticsearch.ElasticsearchClientgetInfo()Get information on a DatabasegetNodes()voidindexEntries(ElasticsearchIndexAlias indexAlias, Collection<? extends org.bson.Document> documents, boolean withRefreshIndex) final <T> voidindexEntry(ElasticsearchIndexAlias indexAlias, String id, VitamDocument<T> vitamDocument) final voidpurgeIndexForTesting(ElasticsearchIndexAlias indexAlias) protected voidpurgeIndexForTesting(ElasticsearchIndexAlias indexAlias, Integer tenantId) final voidrefreshIndex(ElasticsearchIndexAlias indexAlias) final co.elastic.clients.elasticsearch.core.search.ResponseBody<com.fasterxml.jackson.databind.node.ObjectNode>search(ElasticsearchIndexAlias indexAlias, co.elastic.clients.elasticsearch._types.query_dsl.Query query, String[] esProjection, List<co.elastic.clients.elasticsearch._types.SortOptions> sorts, int offset, Integer limit, Map<String, co.elastic.clients.elasticsearch._types.aggregations.Aggregation> facets) final co.elastic.clients.elasticsearch.core.search.ResponseBody<com.fasterxml.jackson.databind.node.ObjectNode>search(ElasticsearchIndexAlias indexAlias, co.elastic.clients.elasticsearch._types.query_dsl.Query query, String[] esProjection, List<co.elastic.clients.elasticsearch._types.SortOptions> sorts, int offset, Integer limit, Map<String, co.elastic.clients.elasticsearch._types.aggregations.Aggregation> facets, String scrollId, Integer scrollTimeout, boolean trackTotalHits) final co.elastic.clients.elasticsearch.core.search.ResponseBody<com.fasterxml.jackson.databind.node.ObjectNode>searchCrossIndices(Set<ElasticsearchIndexAlias> indexAliases, co.elastic.clients.elasticsearch._types.query_dsl.Query query, String[] esProjection, List<co.elastic.clients.elasticsearch._types.SortOptions> sorts, int offset, Integer limit, Map<String, co.elastic.clients.elasticsearch._types.aggregations.Aggregation> facets, String scrollId, Integer scrollTimeout, boolean trackTotalHits) final voidswitchIndex(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo) <T> voidupdateEntry(ElasticsearchIndexAlias indexAlias, String id, VitamDocument<T> vitamDocument) Update one element fully
-
Field Details
-
DEFAULT_SCROLL_TIMEOUT
public static final int DEFAULT_SCROLL_TIMEOUTdefault limit scroll timeout- See Also:
-
DEFAULT_LIMIT_SCROLL
public static final int DEFAULT_LIMIT_SCROLLdefault limit scroll size- See Also:
-
SCROLL_ACTIVATE_KEYWORD
KEYWORD to activate scroll- See Also:
-
clusterName
-
nodes
-
-
Constructor Details
-
ElasticsearchAccess
Create an ElasticSearch access- Parameters:
clusterName- the name of the Clusternodes- the elasticsearch nodes- Throws:
VitamException- when elasticseach node list is empty
-
-
Method Details
-
getAlias
public final co.elastic.clients.elasticsearch.indices.GetAliasResponse getAlias(ElasticsearchIndexAlias indexAlias) throws IOException, co.elastic.clients.elasticsearch._types.ElasticsearchException - Throws:
IOExceptionco.elastic.clients.elasticsearch._types.ElasticsearchException
-
createIndexWithoutAlias
public final ElasticsearchIndexAlias createIndexWithoutAlias(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings, String elasticsearchConfigurationFile) throws DatabaseException - Throws:
DatabaseException
-
existsAlias
- Throws:
DatabaseException
-
existsIndex
- Throws:
DatabaseException
-
refreshIndex
- Throws:
DatabaseException
-
purgeIndexForTesting
protected void purgeIndexForTesting(ElasticsearchIndexAlias indexAlias, Integer tenantId) throws DatabaseException - Throws:
DatabaseException
-
purgeIndexForTesting
- Throws:
DatabaseException
-
indexEntry
public final <T> void indexEntry(ElasticsearchIndexAlias indexAlias, String id, VitamDocument<T> vitamDocument) throws DatabaseException - Throws:
DatabaseException
-
indexEntries
public void indexEntries(ElasticsearchIndexAlias indexAlias, Collection<? extends org.bson.Document> documents, boolean withRefreshIndex) throws DatabaseException - Throws:
DatabaseException
-
updateEntry
public <T> void updateEntry(ElasticsearchIndexAlias indexAlias, String id, VitamDocument<T> vitamDocument) throws DatabaseException Update one element fully- Throws:
DatabaseException
-
search
public final co.elastic.clients.elasticsearch.core.search.ResponseBody<com.fasterxml.jackson.databind.node.ObjectNode> search(ElasticsearchIndexAlias indexAlias, co.elastic.clients.elasticsearch._types.query_dsl.Query query, String[] esProjection, List<co.elastic.clients.elasticsearch._types.SortOptions> sorts, int offset, Integer limit, Map<String, co.elastic.clients.elasticsearch._types.aggregations.Aggregation> facets) throws DatabaseException, BadRequestException- Throws:
DatabaseExceptionBadRequestException
-
searchCrossIndices
public final co.elastic.clients.elasticsearch.core.search.ResponseBody<com.fasterxml.jackson.databind.node.ObjectNode> searchCrossIndices(Set<ElasticsearchIndexAlias> indexAliases, co.elastic.clients.elasticsearch._types.query_dsl.Query query, String[] esProjection, List<co.elastic.clients.elasticsearch._types.SortOptions> sorts, int offset, Integer limit, Map<String, co.elastic.clients.elasticsearch._types.aggregations.Aggregation> facets, String scrollId, Integer scrollTimeout, boolean trackTotalHits) throws DatabaseException, BadRequestException- Throws:
DatabaseExceptionBadRequestException
-
search
public final co.elastic.clients.elasticsearch.core.search.ResponseBody<com.fasterxml.jackson.databind.node.ObjectNode> search(ElasticsearchIndexAlias indexAlias, co.elastic.clients.elasticsearch._types.query_dsl.Query query, String[] esProjection, List<co.elastic.clients.elasticsearch._types.SortOptions> sorts, int offset, Integer limit, Map<String, co.elastic.clients.elasticsearch._types.aggregations.Aggregation> facets, String scrollId, Integer scrollTimeout, boolean trackTotalHits) throws DatabaseException, BadRequestException- Throws:
DatabaseExceptionBadRequestException
-
clearScroll
- Throws:
DatabaseException
-
close
public void close()Close the ElasticSearch connection -
getClusterName
- Returns:
- the Cluster Name
-
getClient
public co.elastic.clients.elasticsearch.ElasticsearchClient getClient()- Returns:
- the client
-
getNodes
- Returns:
- the nodes
-
checkConnection
public boolean checkConnection()Description copied from interface:DatabaseConnectionCheck the connection of the database- Specified by:
checkConnectionin interfaceDatabaseConnection- Returns:
- True if the connection is active
-
getInfo
Description copied from interface:DatabaseConnectionGet information on a Database- Specified by:
getInfoin interfaceDatabaseConnection- Returns:
- information on the database
-
createIndexAndAliasIfAliasNotExists
public final void createIndexAndAliasIfAliasNotExists(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings, String elasticsearchConfigurationFile) throws DatabaseException - Throws:
DatabaseException
-
switchIndex
public final void switchIndex(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo) throws DatabaseException, IOException, co.elastic.clients.elasticsearch._types.ElasticsearchException - Throws:
DatabaseExceptionIOExceptionco.elastic.clients.elasticsearch._types.ElasticsearchException
-
deleteIndexByAliasForTesting
public final void deleteIndexByAliasForTesting(ElasticsearchIndexAlias indexAlias) throws DatabaseException - Throws:
DatabaseException
-
deleteIndexForTesting
public final void deleteIndexForTesting(ElasticsearchIndexAlias indexAlias) throws DatabaseException - Throws:
DatabaseException
-
delete
- Throws:
DatabaseException
-