Package com.hazelcast.jet.elastic
Class ElasticSources
java.lang.Object
com.hazelcast.jet.elastic.ElasticSources
Provides factory methods for Elasticsearch sources.
Alternatively you can use
ElasticSourceBuilder
- Since:
- Jet 4.2
-
Method Summary
Modifier and TypeMethodDescriptionstatic ElasticSourceBuilder<Void>
builder()
Returns new instance ofElasticSourceBuilder
static BatchSource<String>
elastic()
Creates a source which queries local instance of Elasticsearch for all documentsstatic <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<String>
elastic
(SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn) Creates a source which queries Elasticsearch using client obtained fromRestClientBuilder
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 fromRestClientBuilder
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 fromRestHighLevelClient
supplier.
-
Method Details
-
elastic
Creates a source which queries local instance of Elasticsearch for all documentsUseful for quick prototyping. See other methods
elastic(SupplierEx, SupplierEx, FunctionEx)
andbuilder()
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 fromRestClientBuilder
supplier function. Queries all indexes for all documents. UsesSearchHit.getSourceAsString()
as mapping functionFor 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. UsesSearchHit.getSourceAsString()
as mapping functionFor 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 fromRestClientBuilder
supplier function. Uses providedmapToItemFn
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 RestClientBuildermapToItemFn
- 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 fromRestHighLevelClient
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 RestClientBuildersearchRequestFn
- supplier function of a SearchRequest used to query for documentsmapToItemFn
- function mapping the result from a SearchHit to a result type
-
builder
Returns new instance ofElasticSourceBuilder
-