Class AwsRestHighLevelClient

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class AwsRestHighLevelClient
    extends org.elasticsearch.client.RestHighLevelClient
    This class is used to create a new REST client injected with either AWS credentials or username/password credentials.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  AwsRestHighLevelClient.Builder
      A builder for the AwsRestHighLevelClient class.
    • Constructor Summary

      Constructors 
      Constructor Description
      AwsRestHighLevelClient​(org.elasticsearch.client.RestClientBuilder builder)
      Constructs a new client (using a builder) injected with credentials.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Set<String> getAliases()
      Gets the indices from the domain.
      Map<String,​Object> getDocument​(org.elasticsearch.search.SearchHit searchHit)
      Gets the Document from the search hit.
      org.elasticsearch.action.search.SearchResponse getDocuments​(org.elasticsearch.action.search.SearchRequest request)
      Gets the Documents for the specified index and predicate.
      LinkedHashMap<String,​Object> getMapping​(String index)
      Gets the mapping for the specified index.
      Set<Integer> getShardIds​(String index, long timeout)
      Retrieves cluster-health information for shards associated with the specified index.
      • Methods inherited from class org.elasticsearch.client.RestHighLevelClient

        asyncSearch, bulk, bulkAsync, ccr, clearScroll, clearScrollAsync, close, cluster, convertExistsResponse, count, countAsync, delete, deleteAsync, deleteByQuery, deleteByQueryAsync, deleteByQueryRethrottle, deleteByQueryRethrottleAsync, deleteScript, deleteScriptAsync, enrich, eql, exists, existsAsync, existsSource, existsSource, existsSourceAsync, existsSourceAsync, explain, explainAsync, fieldCaps, fieldCapsAsync, get, getAsync, getLowLevelClient, getScript, getScriptAsync, getSource, getSourceAsync, graph, index, indexAsync, indexLifecycle, indices, info, ingest, license, machineLearning, mget, mgetAsync, migration, msearch, msearchAsync, msearchTemplate, msearchTemplateAsync, mtermvectors, mtermvectorsAsync, multiGet, multiGetAsync, multiSearch, multiSearchAsync, parseEntity, parseResponseException, performRequest, performRequestAndParseEntity, performRequestAndParseOptionalEntity, performRequestAsync, performRequestAsyncAndParseEntity, performRequestAsyncAndParseOptionalEntity, ping, putScript, putScriptAsync, rankEval, rankEvalAsync, reindex, reindexAsync, reindexRethrottle, reindexRethrottleAsync, rollup, scroll, scrollAsync, search, searchAsync, searchScroll, searchScrollAsync, searchTemplate, searchTemplateAsync, security, snapshot, submitDeleteByQueryTask, submitReindexTask, submitUpdateByQueryTask, tasks, termvectors, termvectorsAsync, transform, update, updateAsync, updateByQuery, updateByQueryAsync, updateByQueryRethrottle, updateByQueryRethrottleAsync, watcher, xpack
    • Constructor Detail

      • AwsRestHighLevelClient

        public AwsRestHighLevelClient​(org.elasticsearch.client.RestClientBuilder builder)
        Constructs a new client (using a builder) injected with credentials.
        Parameters:
        builder - is used to initialize the super class.
    • Method Detail

      • getAliases

        public Set<String> getAliases()
                               throws IOException
        Gets the indices from the domain.
        Returns:
        a Set containing all the indices retrieved from the specified domain.
        Throws:
        IOException
      • getMapping

        public LinkedHashMap<String,​Object> getMapping​(String index)
                                                      throws IOException
        Gets the mapping for the specified index. For regular index name (table name in Athena), the index name equals to the actual index in ES. For data stream, data stream index does not equals to actual index names, ES created and managed indices for a data stream based on time. therefore, if we use data stream name to find mapping, we will not able to find it. In addition, data stream can contains multiple indices, it is hard to aggregate all the mapping into single giant mapping, we pick up the first index mapping we can find for data stream. Example : non data stream : "book" { "book" : { "mappings" : { .. } } Example: data stream : "datastream" { ".ds-datastream_test1-000001" : { "mappings" : {....} }, ".ds-datastream_test1-12345678" : { "mappings" : {....} }
        Parameters:
        index - is the index whose mapping will be retrieved.
        Returns:
        a map containing all the mapping information for the specified index.
        Throws:
        IOException
      • getShardIds

        public Set<Integer> getShardIds​(String index,
                                        long timeout)
                                 throws RuntimeException,
                                        IOException
        Retrieves cluster-health information for shards associated with the specified index. The request will time out if no results are returned after a period of time indicated by timeout.
        Parameters:
        index - is used to restrict the request to a specified index.
        timeout - is the command timeout period in seconds.
        Returns:
        a set of shard ids for the specified index.
        Throws:
        IOException - if an error occurs while sending the request to the Elasticsearch instance.
        RuntimeException - if the request times out, or no active-primary shards are present.
      • getDocuments

        public org.elasticsearch.action.search.SearchResponse getDocuments​(org.elasticsearch.action.search.SearchRequest request)
                                                                    throws IOException
        Gets the Documents for the specified index and predicate.
        Parameters:
        request - is the search request that includes the projection, predicate, batch size, and from position used for pagination of results.
        Returns:
        the search response including all the document hits.
        Throws:
        IOException
      • getDocument

        public Map<String,​Object> getDocument​(org.elasticsearch.search.SearchHit searchHit)
        Gets the Document from the search hit.
        Parameters:
        searchHit - is the search hit containing the document source.
        Returns:
        the Document as a Map object.