solrjsolr4solr5

Deleting index from Solr using solrj as a client


I am using solrj as client for indexing documents on the solr server.

I am having problem while deleting the indexes by 'id' from the solr server. I am using following code to delete the indexes:

server.deleteById("id:20");
server.commit(true,true);

After this when i again search for the documents, the search result contains the above document also. Dont know what is going wrong with this code. Please help me out with issue.

Thanks!


Solution

  • When you call deleteById, just use the id, without query syntax:

    server.deleteById("20");
    server.commit();