# How to use Spark API to update and insert data in ES

**URL:** <https://discuss.elastic.co/t/how-to-use-spark-api-to-update-and-insert-data-in-es/330216>\
**Category:** Elasticsearch\
**Created:** [April 18, 2023, 11:30am UTC](https://discuss.elastic.co/t/how-to-use-spark-api-to-update-and-insert-data-in-es/330216 "2023-04-18T11:30:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![skyruan](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@skyruan](https://discuss.elastic.co/u/skyruan)\
**Post date:** [April 18, 2023, 11:30am UTC](https://discuss.elastic.co/t/how-to-use-spark-api-to-update-and-insert-data-in-es/330216/1 "2023-04-18T11:30:29Z")

</div>

There is a issue:  
there are 4 fields named id,a,b,c  
if the id is same,i just want to use the latest data to update the value of a，and b,c not handle,  
if the id is different,adding the record in ES

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 16, 2023, 11:30am UTC](https://discuss.elastic.co/t/how-to-use-spark-api-to-update-and-insert-data-in-es/330216/2 "2023-05-16T11:30:30Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
