Class ElasticsearchTransport


  • final class ElasticsearchTransport
    extends java.lang.Object
    Set of predefined functions for REST interaction with elastic search API. Performs HTTP requests and JSON (de)serialization.
    • Constructor Summary

      Constructors 
      Constructor Description
      ElasticsearchTransport​(org.elasticsearch.client.RestClient restClient, com.fasterxml.jackson.databind.ObjectMapper mapper, java.lang.String indexName, int fetchSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void closeScroll​(java.lang.Iterable<java.lang.String> scrollIds)  
      private ElasticsearchMapping fetchAndCreateMapping()
      Build index mapping returning new instance of ElasticsearchMapping.
      (package private) com.fasterxml.jackson.databind.ObjectMapper mapper()  
      (package private) java.util.function.Function<org.apache.http.HttpRequest,​org.elasticsearch.client.Response> rawHttp()  
      (package private) <T> java.util.function.Function<org.apache.http.HttpRequest,​T> rawHttp​(java.lang.Class<T> responseType)  
      (package private) org.elasticsearch.client.RestClient restClient()  
      (package private) java.util.function.Function<java.lang.String,​ElasticsearchJson.Result> scroll()
      Fetches search results given a scrollId.
      (package private) java.util.function.Function<com.fasterxml.jackson.databind.node.ObjectNode,​ElasticsearchJson.Result> search()  
      (package private) java.util.function.Function<com.fasterxml.jackson.databind.node.ObjectNode,​ElasticsearchJson.Result> search​(java.util.Map<java.lang.String,​java.lang.String> httpParams)
      Search request using HTTP post.
      private ElasticsearchVersion version()
      Detects current Elastic Search version by connecting to a existing instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOGGER

        private static final org.slf4j.Logger LOGGER
      • mapper

        private final com.fasterxml.jackson.databind.ObjectMapper mapper
      • restClient

        private final org.elasticsearch.client.RestClient restClient
      • indexName

        final java.lang.String indexName
      • fetchSize

        final int fetchSize
        Default batch size
        See Also:
        Scrolling API
    • Constructor Detail

      • ElasticsearchTransport

        ElasticsearchTransport​(org.elasticsearch.client.RestClient restClient,
                               com.fasterxml.jackson.databind.ObjectMapper mapper,
                               java.lang.String indexName,
                               int fetchSize)
    • Method Detail

      • restClient

        org.elasticsearch.client.RestClient restClient()
      • version

        private ElasticsearchVersion version()
        Detects current Elastic Search version by connecting to a existing instance. It is a GET request to /. Returned JSON has server information (including version).
        Returns:
        parsed version from ES, or ElasticsearchVersion.UNKNOWN
      • mapper

        com.fasterxml.jackson.databind.ObjectMapper mapper()
      • rawHttp

        java.util.function.Function<org.apache.http.HttpRequest,​org.elasticsearch.client.Response> rawHttp()
      • rawHttp

        <T> java.util.function.Function<org.apache.http.HttpRequest,​T> rawHttp​(java.lang.Class<T> responseType)
      • scroll

        java.util.function.Function<java.lang.String,​ElasticsearchJson.Result> scroll()
        Fetches search results given a scrollId.
      • closeScroll

        void closeScroll​(java.lang.Iterable<java.lang.String> scrollIds)
      • search

        java.util.function.Function<com.fasterxml.jackson.databind.node.ObjectNode,​ElasticsearchJson.Result> search()
      • search

        java.util.function.Function<com.fasterxml.jackson.databind.node.ObjectNode,​ElasticsearchJson.Result> search​(java.util.Map<java.lang.String,​java.lang.String> httpParams)
        Search request using HTTP post.