Hi,

I have a plugin that extends the AbstractSolrEventListener. I override the
newSearcher() method and the plan is to add some extra functionality,
namely updating existing documents by setting new values for existing
fields as well as adding new fields to the documents.

I can see that the plugin is invoked and I can get the list of documents,
but I cannot update existing fields or add new fields. I have tried various
approaches, but I cannot get it to work.

If you have any suggestions I would really appreciate it. The code that I
am currently trying is below.

Thank you,
Maria

     for (DocIterator iter = docs.iterator(); iter.hasNext();) {

        int doci = iter.nextDoc();

        Document document = newSearcher.doc(doci);



        SolrInputDocument solrInputDocument1 = new SolrInputDocument();

        AddUpdateCommand addUpdateCommand1 = new AddUpdateCommand(req);

        addUpdateCommand1.clear();

        solrInputDocument1.setField("id", document.get("id"));

        solrInputDocument1.addField("newfield", "newvalue");

        solrInputDocument1.setField("existingfield", "value");

        addUpdateCommand1.solrDoc = solrInputDocument1;

        getCore().getUpdateHandler().addDoc(addUpdateCommand1);


        SolrQueryResponse re = new SolrQueryResponse();

        SolrQueryRequest rq = new LocalSolrQueryRequest(getCore(), new
 ModifiableSolrParams());

        CommitUpdateCommand commit = new CommitUpdateCommand(rq,false);

         getCore().getUpdateHandler().commit(commit);


     }

Reply via email to