T - The type of the element handled by this ElasticsearchSinkFunction@Deprecated @PublicEvolving public interface ElasticsearchSinkFunction<T> extends Serializable, org.apache.flink.api.common.functions.Function
ActionRequests from an element in a stream.
This is used by sinks to prepare elements for sending them to Elasticsearch.
Example:
private static class TestElasticSearchSinkFunction implements
ElasticsearchSinkFunction<Tuple2<Integer, String>> {
public IndexRequest createIndexRequest(Tuple2<Integer, String> element) {
Map<String, Object> json = new HashMap<>();
json.put("data", element.f1);
return Requests.indexRequest()
.index("my-index")
.type("my-type")
.id(element.f0.toString())
.source(json);
}
public void process(Tuple2<Integer, String> element, RuntimeContext ctx, RequestIndexer indexer) {
indexer.add(createIndexRequest(element));
}
}
| Modifier and Type | Method and Description |
|---|---|
default void |
close()
Deprecated.
Tear-down method for the function.
|
default void |
open()
Deprecated.
Initialization method for the function.
|
void |
process(T element,
org.apache.flink.api.common.functions.RuntimeContext ctx,
RequestIndexer indexer)
Deprecated.
Process the incoming element to produce multiple
ActionsRequests. |
default void open()
throws Exception
Exceptiondefault void close()
throws Exception
Exceptionvoid process(T element, org.apache.flink.api.common.functions.RuntimeContext ctx, RequestIndexer indexer)
ActionsRequests. The
produced requests should be added to the provided RequestIndexer.element - incoming element to processctx - runtime context containing information about the sink instanceindexer - request indexer that ActionRequest should be added toCopyright © 2014–2022 The Apache Software Foundation. All rights reserved.