On 5/10/2013 2:57 PM, bbarani wrote:


I am in the process of migrating our existing SOLR (version 3.5) to new
version of SOLR (4.3.0).

Currently we delete the document from SOLR using the below code (deletion
happens via message queue).

     UpdateRequestProcessor processor = _getProcessor(); // return SOLR core
information
     DeleteUpdateCommand deleteCommand = new DeleteUpdateCommand();
     deleteCommand.id = docId;
     deleteCommand.fromPending = true;
     deleteCommand.fromCommitted = true;
     processor.processDelete(deleteCommand);

Where does this code live? UpdateRequestProcessor appears to be part of the core Solr API, which only makes sense if you are writing a custom Solr component or plugin.

Usually making a java program talk to Solr is done with SolrJ. A SolrJ (Java client) program would be very different code:

import java.io.IOException;
import org.apache.solr.client.solrj.SolrServer;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrServer;

        SolrServer server = new HttpSolrServer
            ("host:port/solr/corename");
        String deleteId = "id567";
        String deleteQuery = "docname:foobar";
        try
        {
                server.deleteById(deleteId);
                server.deleteByQuery(deleteQuery);
                server.commit();
        }
        catch (SolrServerException e)
        {
                e.printStackTrace();
        }
        catch (IOException e)
        {
                e.printStackTrace();
        }

Thanks,
Shawn

Reply via email to