You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by bbarani <bb...@gmail.com> on 2013/05/10 22:57:01 UTC

SOLR 4.3.0 - How to use DeleteUpdateCommand?


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);

It looks like the new version of SOLR API has different constructor, it
requires a SOLR request to passed in...So I did something like below.. I
just want to confirm if I am doing this right? Can someone please confirm?
Also is there any migration help document that I can use to overcome
migration related issues?

NamedList<String> nList=new NamedList<String>();
        nList.add("id", docId);  
        LocalSolrQueryRequest req = new LocalSolrQueryRequest(
                _requestHandler.getCore(), nList);
        UpdateRequestProcessor processor = _getProcessor();
        DeleteUpdateCommand deleteCommand = new DeleteUpdateCommand(req);
    processor.processDelete(deleteCommand);





--
View this message in context: http://lucene.472066.n3.nabble.com/SOLR-4-3-0-How-to-use-DeleteUpdateCommand-tp4062454.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: SOLR 4.3.0 - How to use DeleteUpdateCommand?

Posted by bbarani <bb...@gmail.com>.
Shawn,

This is indeed a custom SOLR update component used by the message queue to
perform various operations (add, update , delete etc..). We have implemented
custom logic in this component... 

Thanks,
BB



--
View this message in context: http://lucene.472066.n3.nabble.com/SOLR-4-3-0-Migration-How-to-use-DeleteUpdateCommand-tp4062454p4062477.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: SOLR 4.3.0 - How to use DeleteUpdateCommand?

Posted by Shawn Heisey <so...@elyograg.org>.
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


Re: SOLR 4.3.0 Migration- How to use DeleteUpdateCommand?

Posted by bbarani <bb...@gmail.com>.
I was able to make it work as below..

		SolrQueryResponse rsp = new SolrQueryResponse();
		SolrQueryRequest req = new LocalSolrQueryRequest(
				_requestHandler.getCore(), new ModifiableSolrParams());
		SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
		AddUpdateCommand cmd = new AddUpdateCommand(req);



--
View this message in context: http://lucene.472066.n3.nabble.com/SOLR-4-3-0-Migration-How-to-use-DeleteUpdateCommand-tp4062454p4065027.html
Sent from the Solr - User mailing list archive at Nabble.com.