lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Solr Wiki] Update of "UpdateRequestProcessor" by SimonRosenthal
Date Thu, 04 Aug 2011 17:08:06 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.

The "UpdateRequestProcessor" page has been changed by SimonRosenthal:
http://wiki.apache.org/solr/UpdateRequestProcessor?action=diff&rev1=7&rev2=8

  The [[http://lucene.apache.org/solr/api/org/apache/solr/update/processor/UpdateRequestProcessor.html|UpdateRequestProcessor]]
defines how an update request is processed before it is indexed by the update handler.
  
  == Configuring UpdateRequestProcessors ==
- 
  solrconfig.xml will load a UpdateRequestProcessors
  
- {{{          
-  <updateRequestProcessorChain>                                               
+ {{{
+  <updateRequestProcessorChain>
      <processor class="solr.CustomUpdateRequestProcessorFactory" >
     <lst name="name">
       <str name="n1">x1</str>
       <str name="n2">x2</str>
     </lst>
    </processor>
-                                     
+ 
-    <processor class="solr.RunUpdateProcessorFactory" />                    
+    <processor class="solr.RunUpdateProcessorFactory" />
-    <processor class="solr.LogUpdateProcessorFactory" />                  
+    <processor class="solr.LogUpdateProcessorFactory" />
   </updateRequestProcessorChain>
  }}}
- 
- 
- 
  == Implementing a conditional copyField ==
- 
  Here is a quick example that adds the 'cat' 'popular' if the value of 'popularity' is >
5
  
  {{{
@@ -40, +35 @@

  import org.apache.solr.update.processor.UpdateRequestProcessor;
  import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
  
- public class ConditionalCopyProcessorFactory extends UpdateRequestProcessorFactory 
+ public class ConditionalCopyProcessorFactory extends UpdateRequestProcessorFactory
  {
    @Override
-   public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp,
UpdateRequestProcessor next) 
+   public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp,
UpdateRequestProcessor next)
    {
      return new ConditionalCopyProcessor(next);
    }
  }
  
- class ConditionalCopyProcessor extends UpdateRequestProcessor 
+ class ConditionalCopyProcessor extends UpdateRequestProcessor
  {
    public ConditionalCopyProcessor( UpdateRequestProcessor next) {
      super( next );
    }
-   
+ 
    @Override
    public void processAdd(AddUpdateCommand cmd) throws IOException {
      SolrInputDocument doc = cmd.getSolrInputDocument();
-     
+ 
      Object v = doc.getFieldValue( "popularity" );
      if( v != null ) {
        int pop = Integer.parseInt( v.toString() );
@@ -66, +61 @@

          doc.addField( "cat", "popular" );
        }
      }
-     
+ 
      // pass it up the chain
      super.processAdd(cmd);
    }
  }
- 
  }}}
  

Mime
View raw message