Class Elastic
- java.lang.Object
-
- fr.paris.lutece.plugins.libraryelastic.util.Elastic
-
public class Elastic extends Object
Elastic
-
-
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 idStringcreateByBulk(String strIndex, BulkRequest bulkRequest)perform a bulk indexing of documents : this is used for indexing thousand doc with one HTTP callStringcreateMappings(String strIndex, String strJsonMappings)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 indexbooleanisExists(String strIndex)Check if a given index existsStringpartialUpdate(String strIndex, String strId, Object object)Partial Updates to DocumentsStringsearch(String strIndex, SearchRequest search)Search a document of given type into a given indexStringsearch(String strIndex, String searchRequest)SearchStringsuggest(String strIndex, AbstractSuggestRequest suggest)suggest a list of document of given type into a given index The suggest is done with a _search request with size set to 0 to avoid fetch in 'hits' so be careful with the JSON resultStringsuggest(String strIndex, String strJSON)suggest a list of document of given type into a given index The suggest is done with a _search request with size set to 0 to avoid fetch in 'hits' so be careful with the JSON result
-
-
-
Constructor Detail
-
Elastic
public Elastic(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
-
createByBulk
public String createByBulk(String strIndex, BulkRequest bulkRequest) throws ElasticClientException
perform a bulk indexing of documents : this is used for indexing thousand doc with one HTTP call- Parameters:
strIndex- the elk index namebulkRequest- the bulkRequest- 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
-
partialUpdate
public String partialUpdate(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
-
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, SearchRequest 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 indexstrSearchRequest- search request- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
suggest
public String suggest(String strIndex, AbstractSuggestRequest suggest) throws ElasticClientException
suggest a list of document of given type into a given index The suggest is done with a _search request with size set to 0 to avoid fetch in 'hits' so be careful with the JSON result- Parameters:
strIndex- The indexsuggest- suggest request- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
suggest
public String suggest(String strIndex, String strJSON) throws ElasticClientException
suggest a list of document of given type into a given index The suggest is done with a _search request with size set to 0 to avoid fetch in 'hits' so be careful with the JSON result- Parameters:
strIndex- The indexstrJSON- suggest request- Returns:
- The JSON response from Elastic
- Throws:
ElasticClientException- If a problem occurs connecting Elastic
-
createMappings
public String createMappings(String strIndex, String strJsonMappings) throws ElasticClientException
- Parameters:
strIndex-strJsonMappings-- Returns:
- Throws:
ElasticClientException
-
-