lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elmerfudd <na...@012.net.il>
Subject custom updateHandler
Date Thu, 02 Jan 2014 16:48:40 GMT
*ok im really lost...
Im trying to set a custom updatehandler 
ran into this:
*

package my.solr;
//imports were here - deleted for shorting.
 
public class myPlugin extends UpdateRequestProcessorFactory
{
  @Override
  public UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp, UpdateRequestProcessor next)
  {
    return new ConditionalCopyProcessor(next);
  }
}

class ConditionalCopyProcessor extends UpdateRequestProcessor
{
  public ConditionalCopyProcessor( UpdateRequestProcessor next) {
    super( next );
  }

  @Override
  public void processAdd(AddUpdateCommand cmd) throws IOException {
    SolrInputDocument doc = cmd.getSolrInputDocument();
    
    doc.setField("price", 12);
    Object v = doc.getFieldValue( "popularity" );
    if( v != null ) {
      int pop = Integer.parseInt( v.toString() );
      if( pop > 5 ) {
        doc.addField( "cat", "Itzik" );
      }
    }
    doc.addField( "cat", "naaa" );
    // pass it up the chain
    cmd.solrDoc.setField("price", 12);
    
    super.processAdd(cmd);
  }
}



*then in the solrconfig of the collection 
changed update handler like so:*

   <requestHandler name="/update"   
class="solr.UpdateRequestHandler" > 
     <lst name="invariants"> 
      <str name="update.processor">KeepIndexed</str> 
     </lst> 
   </requestHandler> 

<updateRequestProcessorChain name="KeepIndexed"> 
     <processor class="my.solr.myPlugin"/> 
    <processor class="solr.RunUpdateProcessorFactory" /> 
    <processor class="solr.LogUpdateProcessorFactory" /> 
</updateRequestProcessorChain> 


*
I put the jar made from the class myPlugin in the lib folder.
add :
  <lib dir="../../lib/" regex=".*\.jar" />

to the lib section in solrconfig



then trying to index a file - but the field wont change!

how come?

*




--
View this message in context: http://lucene.472066.n3.nabble.com/custom-updateHandler-tp4109153.html
Sent from the Solr - User mailing list archive at Nabble.com.

Mime
View raw message