public final class ElasticSources extends Object
ElasticSourceBuilder
Modifier and Type | Method and Description |
---|---|
static ElasticSourceBuilder<Void> |
builder()
Returns new instance of
ElasticSourceBuilder |
static BatchSource<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<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. |
@Nonnull public static BatchSource<String> elastic()
Useful for quick prototyping. See other methods
elastic(SupplierEx, SupplierEx, FunctionEx)
and
builder()
For example:
pipeline.readFrom(ElasticSources.elastic());
@Nonnull public static BatchSource<String> elastic(@Nonnull SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn)
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),
));
clientFn
- supplier function returning configured RestClientBuilder@Nonnull public static <T> BatchSource<T> elastic(@Nonnull FunctionEx<? super org.elasticsearch.search.SearchHit,T> mapToItemFn)
SearchHit.getSourceAsString()
as mapping
function
For example:
pipeline.readFrom(ElasticSources.elastic(
SearchHit::getSourceAsMap
));
T
- result type returned by the map functionmapToItemFn
- function mapping the result from a SearchHit to a
result type@Nonnull public static <T> BatchSource<T> elastic(@Nonnull SupplierEx<org.elasticsearch.client.RestClientBuilder> clientFn, @Nonnull FunctionEx<? super org.elasticsearch.search.SearchHit,T> mapToItemFn)
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
));
T
- result type returned by the map functionclientFn
- supplier function returning configured
RestClientBuildermapToItemFn
- function mapping the result from a SearchHit to a
result type@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)
RestHighLevelClient
supplier.
For example:
pipeline.readFrom(ElasticSources.elastic(
() -> ElasticClients.client("localhost", 9200),
() -> new SearchRequest("my-index"),
SearchHit::getSourceAsMap
));
T
- result type returned by the map functionclientFn
- 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@Nonnull public static ElasticSourceBuilder<Void> builder()
ElasticSourceBuilder
Copyright © 2023 Hazelcast, Inc.. All rights reserved.