Now that I have set it up using UpdateProcessorChain, I am running into null
exeception.
Here is what I have-
In SolrConfig.xml
<updateRequestProcessorChain name="mychain" >
<processor class="mysolr.AddConditionalFieldsFactory" >
</processor>
<processor class="solr.RunUpdateProcessorFactory" />
<processor class="solr.LogUpdateProcessorFactory" />
</updateRequestProcessorChain>
<requestHandler name="/update/csv" class="solr.CSVRequestHandler"
startup="lazy" >
<lst name="defaults">
<str name="update.chain">mychain</str>
</lst>
</requestHandler>
Here is my java code-
package mysolr;
import java.io.IOException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryResponse;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
public class AddConditionalFieldsFactory extends
UpdateRequestProcessorFactory
{
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req,
SolrQueryResponse rsp, UpdateRequestProcessor next)
{
System.out.println("From customization:");
return new AddConditionalFields(next);
}
}
class AddConditionalFields extends UpdateRequestProcessor
{
public AddConditionalFields( UpdateRequestProcessor next) {
super( next );
}
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
SolrInputDocument doc = cmd.getSolrInputDocument();
Object v = doc.getFieldValue( "url" );
if( v != null ) {
String url = v.toString();
if( url.contains("question") ) {
doc.addField( "tierFilter", "1" );
}
}
// pass it up the chain
super.processAdd(cmd);
}
}
Here is my Java code-
and I get the following error when I try to index-
Aug 20, 2011 10:48:43 AM org.apache.solr.common.SolrException log
SEVERE: java.lang.AbstractMethodError at
org.apache.solr.update.processor.UpdateRequestProcessorChain.createProcessor(UpdateRequestProcessorChain.java:74)
at
org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:53)
Any pointers please. I am using Solr 3.3
Thanks,
Bhawna
On Thu, Aug 18, 2011 at 2:04 PM, simon <[email protected]> wrote:
> An UpdateRequestProcessor would do the trick. Look at the (rather minimal)
> documentation and code example in
> http://wiki.apache.org/solr/UpdateRequestProcessor
>
> -Simon
>
> On Thu, Aug 18, 2011 at 4:15 PM, bhawna singh <[email protected]>
> wrote:
>
> > Hi All,
> > I have a requirement to update a certain field value depending on the
> field
> > value of another field.
> > To elaborate-
> > I have a field called 'popularity' and a field called 'URL'. I need to
> > assign popularity value depending on the domain (URL) ( I have the
> > popularity and domain mapping in a text file).
> >
> > I am using CSVRequestHandler to import the data.
> >
> > What are the suggested ways to achieve this.
> > Your quick response is much appreciated.
> >
> > Thanks,
> > Bhawna
> >
>