Hi Fidea,

I found some examples in the Java documentation, and I hope they can be 
helpful. 

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));
    }
}

But as jiadong mentioned, ElasticsearchSinkFunction is no longer recommended 
for use. 

Best,
Jiabao


On 2024/01/29 11:15:43 Fidea Lidea wrote:
> Hi Team,
> 
> Could you please share with me a few example codes on  how to perform
> "updaterequest on elasticsearch using apache flink"
> I.want to use  ElasticsearchSinkFunction to perform updaterequest.
> 
> Thanks
> Nida Shaikh
> lideafidea...@gmail.com
> 

Reply via email to