Search in sources :

Example 6 with UpdateRequestProcessorChain

use of org.apache.solr.update.processor.UpdateRequestProcessorChain in project lucene-solr by apache.

the class UIMAUpdateRequestProcessorTest method testProcessorConfiguration.

@Test
public void testProcessorConfiguration() {
    SolrCore core = h.getCore();
    UpdateRequestProcessorChain chained = core.getUpdateProcessingChain(UIMA_CHAIN);
    assertNotNull(chained);
    UIMAUpdateRequestProcessorFactory factory = (UIMAUpdateRequestProcessorFactory) chained.getProcessors().get(0);
    assertNotNull(factory);
    UpdateRequestProcessor processor = factory.getInstance(req(), null, null);
    assertTrue(processor instanceof UIMAUpdateRequestProcessor);
}
Also used : SolrCore(org.apache.solr.core.SolrCore) UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain) UpdateRequestProcessor(org.apache.solr.update.processor.UpdateRequestProcessor) Test(org.junit.Test)

Example 7 with UpdateRequestProcessorChain

use of org.apache.solr.update.processor.UpdateRequestProcessorChain in project lucene-solr by apache.

the class SolrCore method loadUpdateProcessorChains.

/**
   * Load the request processors
   */
private Map<String, UpdateRequestProcessorChain> loadUpdateProcessorChains() {
    Map<String, UpdateRequestProcessorChain> map = new HashMap<>();
    UpdateRequestProcessorChain def = initPlugins(map, UpdateRequestProcessorChain.class, UpdateRequestProcessorChain.class.getName());
    if (def == null) {
        def = map.get(null);
    }
    if (def == null) {
        log.debug("no updateRequestProcessorChain defined as default, creating implicit default");
        // construct the default chain
        UpdateRequestProcessorFactory[] factories = new UpdateRequestProcessorFactory[] { new LogUpdateProcessorFactory(), new DistributedUpdateProcessorFactory(), new RunUpdateProcessorFactory() };
        def = new UpdateRequestProcessorChain(Arrays.asList(factories), this);
    }
    map.put(null, def);
    map.put("", def);
    return map;
}
Also used : UpdateRequestProcessorFactory(org.apache.solr.update.processor.UpdateRequestProcessorFactory) RunUpdateProcessorFactory(org.apache.solr.update.processor.RunUpdateProcessorFactory) LogUpdateProcessorFactory(org.apache.solr.update.processor.LogUpdateProcessorFactory) LinkedHashMap(java.util.LinkedHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) DistributedUpdateProcessorFactory(org.apache.solr.update.processor.DistributedUpdateProcessorFactory) UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain)

Example 8 with UpdateRequestProcessorChain

use of org.apache.solr.update.processor.UpdateRequestProcessorChain in project lucene-solr by apache.

the class SolrCore method getUpdateProcessorChain.

public UpdateRequestProcessorChain getUpdateProcessorChain(SolrParams params) {
    String chainName = params.get(UpdateParams.UPDATE_CHAIN);
    UpdateRequestProcessorChain defaultUrp = getUpdateProcessingChain(chainName);
    ProcessorInfo processorInfo = new ProcessorInfo(params);
    if (processorInfo.isEmpty())
        return defaultUrp;
    return UpdateRequestProcessorChain.constructChain(defaultUrp, processorInfo, this);
}
Also used : ProcessorInfo(org.apache.solr.update.processor.UpdateRequestProcessorChain.ProcessorInfo) UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain)

Example 9 with UpdateRequestProcessorChain

use of org.apache.solr.update.processor.UpdateRequestProcessorChain in project lucene-solr by apache.

the class DefaultValueUpdateProcessorTest method processAdd.

/**
   * Runs a document through the specified chain, and returns the final 
   * document used when the chain is completed (NOTE: some chains may 
   * modify the document in place
   */
SolrInputDocument processAdd(final String chain, final SolrInputDocument docIn) throws IOException {
    SolrCore core = h.getCore();
    UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain);
    assertNotNull("No Chain named: " + chain, pc);
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrQueryRequest req = new LocalSolrQueryRequest(core, new ModifiableSolrParams());
    try {
        SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));
        AddUpdateCommand cmd = new AddUpdateCommand(req);
        cmd.solrDoc = docIn;
        UpdateRequestProcessor processor = pc.createProcessor(req, rsp);
        processor.processAdd(cmd);
        return cmd.solrDoc;
    } finally {
        SolrRequestInfo.clearRequestInfo();
        req.close();
    }
}
Also used : LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) SolrQueryResponse(org.apache.solr.response.SolrQueryResponse) LocalSolrQueryRequest(org.apache.solr.request.LocalSolrQueryRequest) SolrQueryRequest(org.apache.solr.request.SolrQueryRequest) SolrCore(org.apache.solr.core.SolrCore) UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain) UpdateRequestProcessor(org.apache.solr.update.processor.UpdateRequestProcessor) SolrRequestInfo(org.apache.solr.request.SolrRequestInfo) AddUpdateCommand(org.apache.solr.update.AddUpdateCommand) ModifiableSolrParams(org.apache.solr.common.params.ModifiableSolrParams)

Example 10 with UpdateRequestProcessorChain

use of org.apache.solr.update.processor.UpdateRequestProcessorChain in project lucene-solr by apache.

the class TestXIncludeConfig method testXInclude.

public void testXInclude() throws Exception {
    SolrCore core = h.getCore();
    assertNotNull("includedHandler is null", core.getRequestHandler("includedHandler"));
    UpdateRequestProcessorChain chain = core.getUpdateProcessingChain("special-include");
    assertNotNull("chain is missing included processor", chain);
    assertEquals("chain with inclued processor is wrong size", 1, chain.getProcessors().size());
    assertEquals("chain has wrong included processor", RegexReplaceProcessorFactory.class, chain.getProcessors().get(0).getClass());
    IndexSchema schema = core.getLatestSchema();
    // xinclude
    assertNotNull("ft-included is null", schema.getFieldTypeByName("ft-included"));
    assertNotNull("field-included is null", schema.getFieldOrNull("field-included"));
    // entity include
    assertNotNull("ft-entity-include1 is null", schema.getFieldTypeByName("ft-entity-include1"));
    assertNotNull("ft-entity-include2 is null", schema.getFieldTypeByName("ft-entity-include2"));
    // sanity check
    assertNull(// Does Not Exist Anywhere
    "ft-entity-include3 is not null", schema.getFieldTypeByName("ft-entity-include3"));
}
Also used : UpdateRequestProcessorChain(org.apache.solr.update.processor.UpdateRequestProcessorChain) IndexSchema(org.apache.solr.schema.IndexSchema)

Aggregations

UpdateRequestProcessorChain (org.apache.solr.update.processor.UpdateRequestProcessorChain)14 UpdateRequestProcessor (org.apache.solr.update.processor.UpdateRequestProcessor)10 SolrQueryRequest (org.apache.solr.request.SolrQueryRequest)5 SolrCore (org.apache.solr.core.SolrCore)4 SolrQueryResponse (org.apache.solr.response.SolrQueryResponse)4 AddUpdateCommand (org.apache.solr.update.AddUpdateCommand)4 Map (java.util.Map)3 SolrException (org.apache.solr.common.SolrException)3 SolrInputDocument (org.apache.solr.common.SolrInputDocument)3 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)3 SolrParams (org.apache.solr.common.params.SolrParams)3 LocalSolrQueryRequest (org.apache.solr.request.LocalSolrQueryRequest)3 UpdateRequestProcessorFactory (org.apache.solr.update.processor.UpdateRequestProcessorFactory)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 ContentStream (org.apache.solr.common.util.ContentStream)2 SolrRequestInfo (org.apache.solr.request.SolrRequestInfo)2 CommitUpdateCommand (org.apache.solr.update.CommitUpdateCommand)2 Test (org.junit.Test)2 IOException (java.io.IOException)1