Class ElasticSources


  • public final class ElasticSources
    extends java.lang.Object
    Provides factory methods for Elasticsearch sources. Alternatively you can use ElasticSourceBuilder
    Since:
    Jet 4.2
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ElasticSourceBuilder<java.lang.Void> builder()
      Returns new instance of ElasticSourceBuilder
      static BatchSource<java.lang.String> elastic()
      Creates a source which queries local instance of Elasticsearch for all documents
      static <T> BatchSource<T> elastic​(FunctionEx<? super org.elasticsearch.search.SearchHit,​T> mapToItemFn)
      Creates a source which queries local instance of Elasticsearch for all documents.
      static BatchSource<java.lang.String> elastic​(SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn)
      Creates a source which queries Elasticsearch using client obtained from RestClientBuilder supplier function.
      static <T> BatchSource<T> elastic​(SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn, FunctionEx<? super org.elasticsearch.search.SearchHit,​T> mapToItemFn)
      Creates a source which queries Elasticsearch using client obtained from RestClientBuilder supplier function.
      static <T> BatchSource<T> elastic​(SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn, SupplierEx<org.elasticsearch.action.search.SearchRequest> searchRequestFn, FunctionEx<? super org.elasticsearch.search.SearchHit,​T> mapToItemFn)
      Creates a source which queries Elasticsearch using client obtained from RestHighLevelClient supplier.
      • Methods inherited from class java.lang.Object

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

      • elastic

        @Nonnull
        public static BatchSource<java.lang.String> elastic()
        Creates a source which queries local instance of Elasticsearch for all documents

        Useful for quick prototyping. See other methods elastic(SupplierEx, SupplierEx, FunctionEx) and builder()

        For example:

        
         pipeline.readFrom(ElasticSources.elastic());
         
      • elastic

        @Nonnull
        public static BatchSource<java.lang.String> elastic​(@Nonnull
                                                            SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn)
        Creates a source which queries Elasticsearch using client obtained from RestClientBuilder supplier function. Queries all indexes for all documents. Uses SearchHit.getSourceAsString() as mapping function

        For example:

        
         pipeline.readFrom(ElasticSources.elastic(
           () -> ElasticClients.client("localhost", 9200),
         ));
         
        Parameters:
        clientFn - supplier function returning configured RestClientBuilder
      • elastic

        @Nonnull
        public static <T> BatchSource<T> elastic​(@Nonnull
                                                 FunctionEx<? super org.elasticsearch.search.SearchHit,​T> mapToItemFn)
        Creates a source which queries local instance of Elasticsearch for all documents. Uses SearchHit.getSourceAsString() as mapping function

        For example:

        
         pipeline.readFrom(ElasticSources.elastic(
           SearchHit::getSourceAsMap
         ));
         
        Type Parameters:
        T - result type returned by the map function
        Parameters:
        mapToItemFn - function mapping the result from a SearchHit to a result type
      • elastic

        @Nonnull
        public static <T> BatchSource<T> elastic​(@Nonnull
                                                 SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn,
                                                 @Nonnull
                                                 FunctionEx<? super org.elasticsearch.search.SearchHit,​T> mapToItemFn)
        Creates a source which queries Elasticsearch using client obtained from RestClientBuilder supplier function. Uses provided mapToItemFn to map results. Queries all indexes for all documents.

        For example:

        
         pipeline.readFrom(ElasticSources.elastic(
           () -> ElasticClients.client("localhost", 9200),
           SearchHit::getSourceAsMap
         ));
         
        Type Parameters:
        T - result type returned by the map function
        Parameters:
        clientFn - supplier function returning configured RestClientBuilder
        mapToItemFn - function mapping the result from a SearchHit to a result type
      • elastic

        @Nonnull
        public static <T> BatchSource<T> elastic​(@Nonnull
                                                 SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn,
                                                 @Nonnull
                                                 SupplierEx<org.elasticsearch.action.search.SearchRequest> searchRequestFn,
                                                 @Nonnull
                                                 FunctionEx<? super org.elasticsearch.search.SearchHit,​T> mapToItemFn)
        Creates a source which queries Elasticsearch using client obtained from RestHighLevelClient supplier.

        For example:

        
         pipeline.readFrom(ElasticSources.elastic(
           () -> ElasticClients.client("localhost", 9200),
           () -> new SearchRequest("my-index"),
           SearchHit::getSourceAsMap
         ));
         
        Type Parameters:
        T - result type returned by the map function
        Parameters:
        clientFn - supplier function returning configured RestClientBuilder
        searchRequestFn - supplier function of a SearchRequest used to query for documents
        mapToItemFn - function mapping the result from a SearchHit to a result type