Skip to content

In Apache Solr How to retrieve deleted documents

Whenever I am indexing Documents using solr ,my core deleted documents count also getting increased .I want to see the documents which are getting deleted.


You can attach a Listener and log entries before they will be deleted. You can also write them inside a custom file which contains only deleted entries details.

You can implement your own logic too with that code example when you delete entries :


import org.apache.Solr.client.Solrj.SolrClient; 
import org.apache.Solr.client.Solrj.SolrServerException; 
import org.apache.Solr.client.Solrj.impl.HttpSolrClient; 
import org.apache.Solr.common.SolrInputDocument;  

public class DeletingAllDocuments { 
   public static void main(String args[]) throws SolrServerException, IOException {
      //Preparing the Solr client 
      String urlString = "http://localhost:8983/Solr/my_core"; 
      SolrClient Solr = new HttpSolrClient.Builder(urlString).build();   
      //Preparing the Solr document 
      SolrInputDocument doc = new SolrInputDocument();   
      //Deleting the documents from Solr 
      //Saving the document 
      System.out.println("Documents deleted");