How to identiry duplicates and delete it in index

We are looking for an API query approch