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
Modifier and TypeFieldDescriptionprotected final String
static final int
default limit scroll sizestatic final int
default limit scroll timeoutprotected final List<ElasticsearchNode>
static final String
KEYWORD to activate scroll -
Constructor Summary
ConstructorDescriptionElasticsearchAccess
(String clusterName, List<ElasticsearchNode> nodes) Create an ElasticSearch access -
Method Summary
Modifier and TypeMethodDescriptionboolean
Check the connection of the databasevoid
clearScroll
(String scrollId) void
close()
Close the ElasticSearch connectionfinal void
createIndexAndAliasIfAliasNotExists
(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings, String elasticsearchConfigurationFile) final ElasticsearchIndexAlias
createIndexWithoutAlias
(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings, String elasticsearchConfigurationFile) void
delete
(ElasticsearchIndexAlias indexAlias, List<String> ids) final void
deleteIndexByAliasForTesting
(ElasticsearchIndexAlias indexAlias) final void
deleteIndexForTesting
(ElasticsearchIndexAlias indexAlias) final boolean
existsAlias
(ElasticsearchIndexAlias indexAlias) final boolean
final co.elastic.clients.elasticsearch.indices.GetAliasResponse
getAlias
(ElasticsearchIndexAlias indexAlias) co.elastic.clients.elasticsearch.ElasticsearchClient
getInfo()
Get information on a DatabasegetNodes()
void
indexEntries
(ElasticsearchIndexAlias indexAlias, Collection<? extends org.bson.Document> documents, boolean withRefreshIndex) final <T> void
indexEntry
(ElasticsearchIndexAlias indexAlias, String id, VitamDocument<T> vitamDocument) final void
purgeIndexForTesting
(ElasticsearchIndexAlias indexAlias) protected void
purgeIndexForTesting
(ElasticsearchIndexAlias indexAlias, Integer tenantId) final void
refreshIndex
(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) 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 void
switchIndex
(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo) <T> void
updateEntry
(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:
IOException
co.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) throws DatabaseException, BadRequestException - Throws:
DatabaseException
BadRequestException
-
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:
DatabaseException
BadRequestException
-
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:
DatabaseException
BadRequestException
-
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:DatabaseConnection
Check the connection of the database- Specified by:
checkConnection
in interfaceDatabaseConnection
- Returns:
- True if the connection is active
-
getInfo
Description copied from interface:DatabaseConnection
Get information on a Database- Specified by:
getInfo
in 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:
DatabaseException
IOException
co.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
-