Interface ElasticsearchEmitter<T>
-
- Type Parameters:
T- The type of the element handled by thisElasticsearchEmitter
- All Superinterfaces:
org.apache.flink.api.common.functions.Function,Serializable
- All Known Implementing Classes:
MapElasticsearchEmitter
@PublicEvolving public interface ElasticsearchEmitter<T> extends org.apache.flink.api.common.functions.FunctionCreates none or multipleActionRequestsfrom the incoming elements.This is used by sinks to prepare elements for sending them to Elasticsearch.
Example:
private static class TestElasticsearchEmitter implements ElasticsearchEmitter<Tuple2<Integer, String>> { public IndexRequest createIndexRequest(Tuple2<Integer, String> element) { Map<String, Object> document = new HashMap<>(); document.put("data", element.f1); return Requests.indexRequest() .index("my-index") .type("my-type") .id(element.f0.toString()) .source(document); } public void emit(Tuple2<Integer, String> element, RequestIndexer indexer) { indexer.add(createIndexRequest(element)); } }
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()Tear-down method for the function.voidemit(T element, org.apache.flink.api.connector.sink2.SinkWriter.Context context, RequestIndexer indexer)Process the incoming element to produce multipleActionRequests.default voidopen()Initialization method for the function.
-
-
-
Method Detail
-
open
default void open() throws ExceptionInitialization method for the function. It is called once before the actual working process methods.- Throws:
Exception
-
close
default void close() throws ExceptionTear-down method for the function. It is called when the sink closes.- Throws:
Exception
-
emit
void emit(T element, org.apache.flink.api.connector.sink2.SinkWriter.Context context, RequestIndexer indexer)
Process the incoming element to produce multipleActionRequests. The produced requests should be added to the providedRequestIndexer.- Parameters:
element- incoming element to processcontext- to access additional information about the recordindexer- request indexer thatActionRequestshould be added to
-
-