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 Stringcreate(String strIndex, Object object)Create a document of given type into a given indexStringcreate(String strIndex, String strId, Object object)Create a document of given type into a given index at the given idStringcreateAlias(String strIndex, String alias)voidcreateMappings(String strIndex, String strJsonMappings)StringdeleteAlias(String strIndex, String alias)StringdeleteByQuery(String strIndex, String strQuery)Delete a documents by QueryStringdeleteDocument(String strIndex, String strId)Delete a document based on its id in the indexStringdeleteIndex(String strIndex)Delete a given indexStringget(String strIndex, String strId)SearchStringgetAlias(String alias)StringindexByBulk(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 existsStringmultiSearch(String strIndex, List<MultiSearchAction> searchActions)perform a multi search of documents : used to perform several query with a single http callStringsearch(String strIndex, Object search)Search a document of given type into a given indexStringsearch(String strIndex, String searchRequest)SearchStringupdate(String strIndex, String strId, Object object)Partial Updates to DocumentsStringupdateSettings(String strIndex, String strJsonSettings)
-
-
-
Constructor Detail
-
ElasticClient
public ElasticClient(String strServerUrl)
Constructor- Parameters:
strServerUrl- The Elastic server URL
-
-
Method Detail
-
create
public String create(String strIndex, Object object) throws ElasticClientException
Create a document of given type into a given index- Parameters:
strIndex- The indexobject- The document- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
create
public String 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- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
indexByBulk
public String 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- Returns:
- the reponse of Elk server
- Throws:
ElasticClientException
-
deleteIndex
public String deleteIndex(String strIndex) throws ElasticClientException
Delete a given index- Parameters:
strIndex- The index- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
deleteDocument
public String deleteDocument(String strIndex, String strId) throws ElasticClientException
Delete a document based on its id in the index- Parameters:
strIndex- The indexstrId- The id- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
deleteByQuery
public String deleteByQuery(String strIndex, String strQuery) throws ElasticClientException
Delete a documents by Query- Parameters:
strIndex- The indexstrQuery- The Query- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
update
public String update(String strIndex, String strId, Object object) throws ElasticClientException
Partial Updates to Documents- Parameters:
strIndex- The indexstrId- The document idobject- The document- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
get
public String get(String strIndex, String strId) throws ElasticClientException
Search- Parameters:
strIndex- The indexstrId- the id of the requested document- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
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
-
search
public String 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
-
search
public String search(String strIndex, String searchRequest) throws ElasticClientException
Search- Parameters:
strIndex- The indexsearchRequest- search request- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
multiSearch
public String 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 String updateSettings(String strIndex, String strJsonSettings) throws ElasticClientException
- Parameters:
strIndex-strJsonSettings-- Returns:
- Throws:
ElasticClientException
-
createAlias
public String createAlias(String strIndex, String alias) throws ElasticClientException
- Parameters:
strIndex-alias-- Returns:
- Throws:
ElasticClientException
-
getAlias
public String getAlias(String alias) throws ElasticClientException
- Parameters:
alias-- Returns:
- Throws:
ElasticClientException
-
deleteAlias
public String deleteAlias(String strIndex, String alias) throws ElasticClientException
- Parameters:
strIndex-alias-- Returns:
- Throws:
ElasticClientException
-
isAlive
public boolean isAlive()
-
-