Class ElasticSources

java.lang.Object
com.hazelcast.jet.elastic.ElasticSources

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

    • elastic

      @Nonnull public static BatchSource<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<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
    • builder

      @Nonnull public static ElasticSourceBuilder<Void> builder()
      Returns new instance of ElasticSourceBuilder