FAQ
*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.

Search Discussions

  • Shawn Heisey at Jan 2, 2014 at 5:22 pm

    On 1/2/2014 9:48 AM, elmerfudd wrote:
    *ok im really lost...
    Im trying to set a custom updatehandler <snip>
    then trying to index a file - but the field wont change!

    how come?
    At a quick glance, it all looks right, but I could be completely wrong
    about that. I made my custom update chain the default, because it was
    the only way I could find to make it work with the dataimporter.

    As a troubleshooting step, you should create a static logger object and
    put a logging call at the WARN level in your code just to see whether
    it's being called. Here's a code excerpt for this:

    ----

    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;

    public class myPlugin extends UpdateRequestProcessorFactory
    {
        private final static Logger LOG = LoggerFactory
                  .getLogger(myPlugin.class);

    // snipped out your real code here.

        @Override
        public void processAdd(AddUpdateCommand cmd) throws IOException {
          LOG.warn("Logging statement to make sure it's being called.");

    ----

    Just FYI - Java convention says your class should be named MyPlugin, not
    myPlugin. Either will work, but generally speaking identifiers that
    start with lowercase letters are variables, not class names.

    Thanks,
    Shawn
  • Chris Hostetter at Jan 2, 2014 at 10:56 pm
    : <requestHandler name="/update"
    : class="solr.UpdateRequestHandler" >
    : <lst name="invariants">
    : <str name="update.processor">KeepIndexed</str>
    : </lst>
    : </requestHandler>


    Unless you are using Solr 3.1 (or earlier) "update.processor" is a
    meaningless request param ... the param name you need to specify is
    "update.chain"...

    https://wiki.apache.org/solr/UpdateRequestProcessor

    If you can tell us where you saw incorrect examples/docs/advice to use
    "update.processor" we can try to fix those so other people don't make the
    same mistake.


    -Hoss
    http://www.lucidworks.com/
  • Itzikgili at Jan 5, 2014 at 4:24 pm
    I am facing the same issue! if i want to write some code to do the job what
    should i do? all you have in the link u provided is the config section of
    the job.



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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupsolr-user @
categorieslucene
postedJan 2, '14 at 4:49p
activeJan 5, '14 at 4:24p
posts4
users4
websitelucene.apache.org...

People

Translate

site design / logo © 2018 Grokbase