Class ElasticClient
- java.lang.Object
-
- fr.paris.lutece.plugins.identitystore.service.indexer.elastic.client.ElasticClient
-
public class ElasticClient extends Object
-
-
Constructor Summary
Constructors Constructor Description ElasticClient(String strServerUrl)ConstructorElasticClient(String strServerUrl, String strServerLogin, String strServerPwd)Basic Authentification constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAliasOnIndex(AliasActions aliasActions)booleanaliasExists(String strAlias)Check if a given alias existsvoidcreate(String strIndex, String strId, Object object)Create a document of given type into a given index at the given idvoidcreateMappings(String strIndex, String strJsonMappings)voiddeleteAlias(String strIndex, String alias)voiddeleteDocument(String strIndex, String strId)Delete a document based on its id in the indexvoiddeleteIndex(String strIndex)Delete a given indexStringget(String strIndex, String strId)StringgetAlias(String alias)voidindexByBulk(String strIndex, List<BulkAction> bulkActions)perform a bulk indexing of documents : this is used for indexing thousand doc with one HTTP callbooleanisAlive()booleanisExists(String strIndex)Check if a given index existsbooleanisWriteable(String strIndex)Check if a given index is not in read only modeResponsesmultiSearch(String strIndex, List<MultiSearchAction> searchActions)perform a multi search of documents : used to perform several query with a single http callResponsesearch(String strIndex, Object search)Search a document of given type into a given indexvoidupdate(String strIndex, String strId, Object object)Partial Updates to DocumentsvoidupdateSettings(String strIndex, String strJsonSettings)
-
-
-
Constructor Detail
-
ElasticClient
public ElasticClient(String strServerUrl)
Constructor- Parameters:
strServerUrl- The Elastic server URL
-
-
Method Detail
-
create
public void create(String strIndex, String strId, Object object) throws ElasticClientException
Create a document of given type into a given index at the given id- Parameters:
strIndex- The indexstrId- The document idobject- The document- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
indexByBulk
public void indexByBulk(String strIndex, List<BulkAction> bulkActions) throws ElasticClientException
perform a bulk indexing of documents : this is used for indexing thousand doc with one HTTP call- Parameters:
strIndex- the elk index namebulkActions- the actions- Throws:
ElasticClientException
-
deleteIndex
public void deleteIndex(String strIndex) throws ElasticClientException
Delete a given index- Parameters:
strIndex- The index- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
deleteDocument
public void deleteDocument(String strIndex, String strId) throws ElasticClientException
Delete a document based on its id in the index- Parameters:
strIndex- The indexstrId- The id- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
update
public void update(String strIndex, String strId, Object object) throws ElasticClientException
Partial Updates to Documents- Parameters:
strIndex- The indexstrId- The document idobject- The document- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
get
public String get(String strIndex, String strId) throws ElasticClientException
- Parameters:
strIndex- the index of the documentstrId- the id of the document- Returns:
- the document if any
- Throws:
ElasticClientException
-
isExists
public boolean isExists(String strIndex) throws ElasticClientException
Check if a given index exists- Parameters:
strIndex- The index- Returns:
- if th index exists
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
isWriteable
public boolean isWriteable(String strIndex)
Check if a given index is not in read only mode- Parameters:
strIndex- The index- Returns:
- true if the index exists and is writable
-
search
public Response search(String strIndex, Object search) throws ElasticClientException
Search a document of given type into a given index- Parameters:
strIndex- The indexsearch- search request- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
multiSearch
public Responses multiSearch(String strIndex, List<MultiSearchAction> searchActions) throws ElasticClientException
perform a multi search of documents : used to perform several query with a single http call- Parameters:
strIndex- the elk index namesearchActions- the actions- Returns:
- the reponse of Elk server
- Throws:
ElasticClientException
-
createMappings
public void createMappings(String strIndex, String strJsonMappings) throws ElasticClientException
- Parameters:
strIndex-strJsonMappings-- Throws:
ElasticClientException
-
updateSettings
public void updateSettings(String strIndex, String strJsonSettings) throws ElasticClientException
- Parameters:
strIndex-strJsonSettings-- Throws:
ElasticClientException
-
addAliasOnIndex
public void addAliasOnIndex(AliasActions aliasActions) throws ElasticClientException
- Parameters:
strIndex-alias-- Throws:
ElasticClientException
-
getAlias
public String getAlias(String alias) throws ElasticClientException
- Parameters:
alias-- Returns:
- Throws:
ElasticClientException
-
aliasExists
public boolean aliasExists(String strAlias)
Check if a given alias exists- Parameters:
strAlias- The indexThe alias- Returns:
- if th index exists
-
deleteAlias
public void deleteAlias(String strIndex, String alias) throws ElasticClientException
- Parameters:
strIndex-alias-- Throws:
ElasticClientException
-
isAlive
public boolean isAlive()
-
-