Thanks a lot for all your replies. I finally wrote a program which will fetch and store all the UID from source (DB) in one list and fetch and store all the UID from SOLR document in another list.
Next using the binarySearch method of collection I was able to filter out the list of UID's that are not present in SOLR UID list with that of DB UID list and passed those UID for deletion using deletebyQuery. It took under 7 minutes to compare 2 list with over 3 million records (in each list) and delete the orphan documents from SOLR index. Again thanks a lot for all your replies. Thanks, Barani -- View this message in context: http://lucene.472066.n3.nabble.com/How-to-delete-a-SOLR-document-if-that-particular-data-doesnt-exist-in-DB-tp1739222p1761093.html Sent from the Solr - User mailing list archive at Nabble.com.