Class Elastic


  • public class Elastic
    extends Object
    Elastic
    • Constructor Detail

      • Elastic

        public Elastic​(String strServerUrl)
        Constructor
        Parameters:
        strServerUrl - The Elastic server URL
      • Elastic

        public Elastic​(String strServerUrl,
                       String strServerLogin,
                       String strServerPwd)
        Basic Authentification constructor
        Parameters:
        strServerUrl - The Elastic server URL
        strServerLogin - Login
        strServerPwd - Password
    • 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 index
        object - 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 index
        strId - The document id
        object - 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 name
        bulkRequest - the bulkRequest
        Returns:
        the reponse of Elk server
        Throws:
        ElasticClientException
      • deleteDocument

        public String deleteDocument​(String strIndex,
                                     String strId)
                              throws ElasticClientException
        Delete a document based on its id in the index
        Parameters:
        strIndex - The index
        strId - The id
        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 index
        strId - The document id
        object - 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
      • 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 index
        suggest - 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 index
        strJSON - suggest request
        Returns:
        The JSON response from Elastic
        Throws:
        ElasticClientException - If a problem occurs connecting Elastic