'Is there any way to delete documents from elastic search index using Apache Spark on the basis of dataset

I am using the below apache-spark code for updating/inserting records in the elastic search index.

dataset.write().format("org.elasticsearch.spark.sql").option("es.nodes.wan.only", "false")
        .option("es.nodes.discovery", "true").option("es.nodes.client.only", "false")
        .option("es.mapping.id", "id").option("es.write.operation", "upsert").option("es.port","port")  .option("es.nodes","ip").mode("append").save("indexname");

Now I want to delete particular documents from the elastic search index using the dataset in apache-spark.

We are using the 'upsert' option for updating/inserting documents in the elastic search index. Is there any option available to delete records from the elastic search index?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source