Deleting duplicates in index using API query

I an in search of a query to to delete the duplicates for below example

index data:

name product sale id
sai pen 100 1
kumar car 30 2
sai pen 100 1
sai pen 100 1
ram bike 288 3
kumar car 30 2

After deleting duplicates my index should loook like below,

name product sale id
sai pen 100 1
ram bike 288 3
kumar car 30 2

Please do not open multiple threads on the same topic. This has already been asked and answered here and here.