Custom URP example (deprecated)
|
The DSE custom URP implementation is deprecated.
A custom URP is almost always unnecessary.
Instead, DataStax recommends using the field input/output transformer (FIT) API.
Note that the FIT requires a trailing |
DSE Search includes the released version of a plugin API for Solr updates and a plugin to the CassandraDocumentReader. The plugin API transforms data from the secondary indexing API before data is submitted. The plugin to the CassandraDocumentReader transforms the results data from the database to DSE Search.
Using the API, applications can tweak a search document before it is mapped and indexed according to the index schema.
To use the API, do the following:
-
Configure the custom URP in your
solrconfig.xml:solrconfig.xml<dseUpdateRequestProcessorChain name="dse"> <processor class="com.datastax.bdp.search.solr.functional.{product-short}UpdateRequestProcessorFactoryExample"> </processor> </dseUpdateRequestProcessorChain> -
Write a class to use the custom URP that extends the Solr
UpdateRequestProcessor. For example:package com.datastax.bdp.search.solr.functional; import java.io.IOException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.datastax.bdp.search.solr.handler.update.CassandraAddUpdateCommand; import com.datastax.bdp.search.solr.handler.update.CassandraCommitUpdateCommand; import org.apache.solr.update.AddUpdateCommand; import org.apache.solr.update.CommitUpdateCommand; import org.apache.solr.update.processor.UpdateRequestProcessor; public class TestUpdateRequestProcessor extends UpdateRequestProcessor { protected final Logger logger = LoggerFactory.getLogger(TestUpdateRequestProcessor.class); public TestUpdateRequestProcessor(UpdateRequestProcessor next) { super(next); } public void processAdd(AddUpdateCommand cmd) throws IOException { if (cmd instanceof CassandraAddUpdateCommand) { logger.info("Processing Cassandra-actuated document update."); } else { logger.info("Processing HTTP-based document update."); } super.processAdd(cmd); } public void processCommit(CommitUpdateCommand cmd) throws IOException { if (cmd instanceof CassandraCommitUpdateCommand) { logger.info("Processing DSE-actuated commit."); } else { logger.info("Processing client-actuated commit."); } super.processCommit(cmd); } } -
Export the class to a JAR, and place the JAR in the location for your installation type. The JAR is added to the
CLASSPATHautomatically.-
Tarball installations:
<install-location>/resources/solr/lib -
Package installations:
/usr/share/dse/solr/lib
-
-
Test your implementation. For example:
package com.datastax.bdp.search.solr.functional; import com.datastax.bdp.search.solr.handler.update.DSEUpdateProcessorFactory; import org.apache.solr.core.SolrCore; import org.apache.solr.update.processor.UpdateRequestProcessor; public class DSEUpdateRequestProcessorFactoryExample extends DSEUpdateProcessorFactory { SolrCore core; public DSEUpdateRequestProcessorFactoryExample(SolrCore core) { this.core = core; } public UpdateRequestProcessor getInstance( UpdateRequestProcessor next) { return new TestUpdateRequestProcessor(next); } }