我被这个问题难住了。我写了一个自定义的 UpdateRequestProcessorFactory。代码是:
package mira;
import java.io.IOException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.processor.UpdateRequestProcessor;
import org.apache.solr.update.processor.UpdateRequestProcessorFactory;
public class MaProcessorFactory extends UpdateRequestProcessorFactory
{
@Override
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
{
return new MaProcessor(next);
}
}
class MaProcessor extends UpdateRequestProcessor
{
public MaProcessor( UpdateRequestProcessor next) {
super( next );
}
@Override
public void processAdd(AddUpdateCommand cmd) throws IOException {
SolrInputDocument doc = cmd.getSolrInputDocument();
Object vid = doc.getFieldValue( "id" );
Object vcontent = doc.getFieldValue( "content" );
doc.setField( "fileurl", vid );
// pass it up the chain
super.processAdd(cmd);
}
}
我通过将类路径设置为
CLASS-PATH: ../../dist/solr-solrj-4.10.1 ../../dist/solr-core-4.10.1.jar
并编译为来编译它
jar cfmv mira.jar Manifest.txt MaProcessor.class MaProcessorFactory.class
Manifest.txt 是
CLASS-PATH: ../../solr-solrj-4.10.1 ../../solr-core-4.10.1.jar
我的 Solrconfig.xml 有
<lib dir="../../" regex="mira.jar" />
作为最后一个指令和
<requestHandler name="/update" class="solr.UpdateRequestHandler">
<lst name="defaults">
<str name="update.chain">concatfld</str>
</lst>
</requestHandler>
<updateRequestProcessorChain name="concatfld">
<processor class="mira.MaProcessorFactory" />
<processor class="solr.LogUpdateProcessorFactory" />
<processor class="solr.RunUpdateProcessorFactory" />
</updateRequestProcessorChain>`
当我跑步时
java -jar start.jar
我收到一个错误
Error creating core [divine-c]: Error loading class 'mira.MaProcessorFactory'
org.apache.solr.common.SolrException: Error loading class 'mira.MaProcessorFactory'
任何帮助将不胜感激。