Custom URP example (deprecated)
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.
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.
The DSE custom URP implementation is deprecated. A custom URP is almost always unnecessary. Instead, DataStax recommends using the field input/output (FIT) transformer API instead. |
Using the API, applications can tweak a search document before it is mapped and indexed according to the index schema.
The field input transformer (FIT) requires a trailing Z for date field values.
Procedure
To use the API:
-
Configure the custom URP in the
solrconfig.xml
.<dseUpdateRequestProcessorChain name="dse"> <processor class="com.datastax.bdp.search.solr.functional.DSEUpdateRequestProcessorFactoryExample"> </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 this location:
-
Tarball installations:
<install-location>/resources/solr/lib
-
Package installations:
/usr/share/dse/solr/lib
The JAR is added to the CLASSPATH automatically.
-
-
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); } }