Class ElasticsearchAccess
- java.lang.Object
-
- fr.gouv.vitam.common.database.server.elasticsearch.ElasticsearchAccess
-
- All Implemented Interfaces:
DatabaseConnection
- Direct Known Subclasses:
ElasticsearchAccessFunctionalAdmin,ElasticsearchAccessMetadata,LogbookElasticsearchAccess
public class ElasticsearchAccess extends java.lang.Object implements DatabaseConnection
Elasticsearch Access
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringclusterNamestatic intDEFAULT_LIMIT_SCROLLdefault limit scroll sizestatic intDEFAULT_SCROLL_TIMEOUTdefault limit scroll timeoutprotected java.util.List<ElasticsearchNode>nodesstatic java.lang.StringSCROLL_ACTIVATE_KEYWORDKEYWORD to activate scroll
-
Constructor Summary
Constructors Constructor Description ElasticsearchAccess(java.lang.String clusterName, java.util.List<ElasticsearchNode> nodes)Create an ElasticSearch access
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheckConnection()Check the connection of the databasevoidclearScroll(java.lang.String scrollId)voidclose()Close the ElasticSearch connectionvoidcreateIndexAndAliasIfAliasNotExists(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings)ElasticsearchIndexAliascreateIndexWithoutAlias(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings)voiddelete(ElasticsearchIndexAlias indexAlias, java.util.List<java.lang.String> ids)voiddeleteIndexByAliasForTesting(ElasticsearchIndexAlias indexAlias)voiddeleteIndexForTesting(ElasticsearchIndexAlias indexAlias)booleanexistsAlias(ElasticsearchIndexAlias indexAlias)booleanexistsIndex(ElasticsearchIndexAlias index)org.elasticsearch.client.GetAliasesResponsegetAlias(ElasticsearchIndexAlias indexAlias)org.elasticsearch.client.RestHighLevelClientgetClient()java.lang.StringgetClusterName()java.lang.StringgetInfo()Get information on a Databasejava.util.List<ElasticsearchNode>getNodes()voidindexEntries(ElasticsearchIndexAlias indexAlias, java.util.Collection<? extends org.bson.Document> documents)<T> voidindexEntry(ElasticsearchIndexAlias indexAlias, java.lang.String id, VitamDocument<T> vitamDocument)voidpurgeIndexForTesting(ElasticsearchIndexAlias indexAlias)protected voidpurgeIndexForTesting(ElasticsearchIndexAlias indexAlias, java.lang.Integer tenantId)voidrefreshIndex(ElasticsearchIndexAlias indexAlias)org.elasticsearch.action.search.SearchResponsesearch(ElasticsearchIndexAlias indexAlias, org.elasticsearch.index.query.QueryBuilder query, org.elasticsearch.index.query.QueryBuilder filter, java.lang.String[] esProjection, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, java.lang.Integer limit)org.elasticsearch.action.search.SearchResponsesearch(ElasticsearchIndexAlias indexAlias, org.elasticsearch.index.query.QueryBuilder query, org.elasticsearch.index.query.QueryBuilder filter, java.lang.String[] esProjection, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, java.lang.Integer limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, boolean trackTotalHits)org.elasticsearch.action.search.SearchResponsesearchCrossIndices(java.util.Set<ElasticsearchIndexAlias> indexAliases, org.elasticsearch.index.query.QueryBuilder query, org.elasticsearch.index.query.QueryBuilder filter, java.lang.String[] esProjection, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, java.lang.Integer limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, boolean trackTotalHits)voidswitchIndex(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo)<T> voidupdateEntry(ElasticsearchIndexAlias indexAlias, java.lang.String id, VitamDocument<T> vitamDocument)Update one element fully
-
-
-
Field Detail
-
DEFAULT_SCROLL_TIMEOUT
public static final int DEFAULT_SCROLL_TIMEOUT
default limit scroll timeout- See Also:
- Constant Field Values
-
DEFAULT_LIMIT_SCROLL
public static final int DEFAULT_LIMIT_SCROLL
default limit scroll size- See Also:
- Constant Field Values
-
SCROLL_ACTIVATE_KEYWORD
public static final java.lang.String SCROLL_ACTIVATE_KEYWORD
KEYWORD to activate scroll- See Also:
- Constant Field Values
-
clusterName
protected final java.lang.String clusterName
-
nodes
protected final java.util.List<ElasticsearchNode> nodes
-
-
Constructor Detail
-
ElasticsearchAccess
public ElasticsearchAccess(java.lang.String clusterName, java.util.List<ElasticsearchNode> nodes) throws VitamExceptionCreate an ElasticSearch access- Parameters:
clusterName- the name of the Clusternodes- the elasticsearch nodes- Throws:
VitamException- when elasticseach node list is empty
-
-
Method Detail
-
getAlias
public final org.elasticsearch.client.GetAliasesResponse getAlias(ElasticsearchIndexAlias indexAlias) throws java.io.IOException
- Throws:
java.io.IOException
-
createIndexWithoutAlias
public final ElasticsearchIndexAlias createIndexWithoutAlias(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings) throws DatabaseException
- Throws:
DatabaseException
-
existsAlias
public final boolean existsAlias(ElasticsearchIndexAlias indexAlias) throws DatabaseException
- Throws:
DatabaseException
-
existsIndex
public final boolean existsIndex(ElasticsearchIndexAlias index) throws DatabaseException
- Throws:
DatabaseException
-
refreshIndex
public final void refreshIndex(ElasticsearchIndexAlias indexAlias) throws DatabaseException
- Throws:
DatabaseException
-
purgeIndexForTesting
protected void purgeIndexForTesting(ElasticsearchIndexAlias indexAlias, java.lang.Integer tenantId) throws DatabaseException
- Throws:
DatabaseException
-
purgeIndexForTesting
public final void purgeIndexForTesting(ElasticsearchIndexAlias indexAlias) throws DatabaseException
- Throws:
DatabaseException
-
indexEntry
public final <T> void indexEntry(ElasticsearchIndexAlias indexAlias, java.lang.String id, VitamDocument<T> vitamDocument) throws DatabaseException
- Throws:
DatabaseException
-
indexEntries
public void indexEntries(ElasticsearchIndexAlias indexAlias, java.util.Collection<? extends org.bson.Document> documents) throws DatabaseException
- Throws:
DatabaseException
-
updateEntry
public <T> void updateEntry(ElasticsearchIndexAlias indexAlias, java.lang.String id, VitamDocument<T> vitamDocument) throws DatabaseException
Update one element fully- Throws:
DatabaseException
-
search
public final org.elasticsearch.action.search.SearchResponse search(ElasticsearchIndexAlias indexAlias, org.elasticsearch.index.query.QueryBuilder query, org.elasticsearch.index.query.QueryBuilder filter, java.lang.String[] esProjection, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, java.lang.Integer limit) throws DatabaseException, BadRequestException
- Throws:
DatabaseExceptionBadRequestException
-
searchCrossIndices
public final org.elasticsearch.action.search.SearchResponse searchCrossIndices(java.util.Set<ElasticsearchIndexAlias> indexAliases, org.elasticsearch.index.query.QueryBuilder query, org.elasticsearch.index.query.QueryBuilder filter, java.lang.String[] esProjection, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, java.lang.Integer limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, boolean trackTotalHits) throws DatabaseException, BadRequestException
- Throws:
DatabaseExceptionBadRequestException
-
search
public final org.elasticsearch.action.search.SearchResponse search(ElasticsearchIndexAlias indexAlias, org.elasticsearch.index.query.QueryBuilder query, org.elasticsearch.index.query.QueryBuilder filter, java.lang.String[] esProjection, java.util.List<org.elasticsearch.search.sort.SortBuilder<?>> sorts, int offset, java.lang.Integer limit, java.util.List<org.elasticsearch.search.aggregations.AggregationBuilder> facets, java.lang.String scrollId, java.lang.Integer scrollTimeout, boolean trackTotalHits) throws DatabaseException, BadRequestException
- Throws:
DatabaseExceptionBadRequestException
-
clearScroll
public void clearScroll(java.lang.String scrollId) throws DatabaseException- Throws:
DatabaseException
-
close
public void close()
Close the ElasticSearch connection
-
getClusterName
public java.lang.String getClusterName()
- Returns:
- the Cluster Name
-
getClient
public org.elasticsearch.client.RestHighLevelClient getClient()
- Returns:
- the client
-
getNodes
public java.util.List<ElasticsearchNode> 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
public java.lang.String 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) throws DatabaseException
- Throws:
DatabaseException
-
switchIndex
public final void switchIndex(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo) throws DatabaseException, java.io.IOException
- Throws:
DatabaseExceptionjava.io.IOException
-
deleteIndexByAliasForTesting
public final void deleteIndexByAliasForTesting(ElasticsearchIndexAlias indexAlias) throws DatabaseException
- Throws:
DatabaseException
-
deleteIndexForTesting
public final void deleteIndexForTesting(ElasticsearchIndexAlias indexAlias) throws DatabaseException
- Throws:
DatabaseException
-
delete
public void delete(ElasticsearchIndexAlias indexAlias, java.util.List<java.lang.String> ids) throws DatabaseException
- Throws:
DatabaseException
-
-