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.String
clusterName
static int
DEFAULT_LIMIT_SCROLL
default limit scroll sizestatic int
DEFAULT_SCROLL_TIMEOUT
default limit scroll timeoutprotected java.util.List<ElasticsearchNode>
nodes
static java.lang.String
SCROLL_ACTIVATE_KEYWORD
KEYWORD 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 boolean
checkConnection()
Check the connection of the databasevoid
clearScroll(java.lang.String scrollId)
void
close()
Close the ElasticSearch connectionvoid
createIndexAndAliasIfAliasNotExists(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings)
ElasticsearchIndexAlias
createIndexWithoutAlias(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexSettings indexSettings)
void
delete(ElasticsearchIndexAlias indexAlias, java.util.List<java.lang.String> ids)
void
deleteIndexByAliasForTesting(ElasticsearchIndexAlias indexAlias)
void
deleteIndexForTesting(ElasticsearchIndexAlias indexAlias)
boolean
existsAlias(ElasticsearchIndexAlias indexAlias)
boolean
existsIndex(ElasticsearchIndexAlias index)
org.elasticsearch.client.GetAliasesResponse
getAlias(ElasticsearchIndexAlias indexAlias)
org.elasticsearch.client.RestHighLevelClient
getClient()
java.lang.String
getClusterName()
java.lang.String
getInfo()
Get information on a Databasejava.util.List<ElasticsearchNode>
getNodes()
void
indexEntries(ElasticsearchIndexAlias indexAlias, java.util.Collection<? extends org.bson.Document> documents)
<T> void
indexEntry(ElasticsearchIndexAlias indexAlias, java.lang.String id, VitamDocument<T> vitamDocument)
void
purgeIndexForTesting(ElasticsearchIndexAlias indexAlias)
protected void
purgeIndexForTesting(ElasticsearchIndexAlias indexAlias, java.lang.Integer tenantId)
void
refreshIndex(ElasticsearchIndexAlias indexAlias)
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)
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)
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)
void
switchIndex(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo)
<T> void
updateEntry(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 VitamException
Create 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:
DatabaseException
BadRequestException
-
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:
DatabaseException
BadRequestException
-
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:
DatabaseException
BadRequestException
-
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:DatabaseConnection
Check the connection of the database- Specified by:
checkConnection
in interfaceDatabaseConnection
- Returns:
- True if the connection is active
-
getInfo
public java.lang.String 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) throws DatabaseException
- Throws:
DatabaseException
-
switchIndex
public final void switchIndex(ElasticsearchIndexAlias indexAlias, ElasticsearchIndexAlias indexNameToSwitchTo) throws DatabaseException, java.io.IOException
- Throws:
DatabaseException
java.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
-
-