Package org.apache.solr.update.processor
Class FieldMutatingUpdateProcessor
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessor
-
- org.apache.solr.update.processor.FieldMutatingUpdateProcessor
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
AllValuesOrNoneFieldMutatingUpdateProcessor,FieldValueMutatingUpdateProcessor
public abstract class FieldMutatingUpdateProcessor extends UpdateRequestProcessor
Reusable base class for UpdateProcessors that will consider AddUpdateCommands and mutate the values associated with configured fields.Subclasses should override the mutate method to specify how individual SolrInputFields identified by the selector associated with this instance will be mutated.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceFieldMutatingUpdateProcessor.FieldNameSelectorInterface for identifying which fields should be mutated
-
Field Summary
Fields Modifier and Type Field Description static FieldMutatingUpdateProcessor.FieldNameSelectorSELECT_ALL_FIELDSSingleton indicating all fields should be mutatedstatic FieldMutatingUpdateProcessor.FieldNameSelectorSELECT_NO_FIELDSSingleton indicating no fields should be mutated-
Fields inherited from class org.apache.solr.update.processor.UpdateRequestProcessor
next
-
-
Constructor Summary
Constructors Constructor Description FieldMutatingUpdateProcessor(FieldMutatingUpdateProcessor.FieldNameSelector selector, UpdateRequestProcessor next)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static FieldMutatingUpdateProcessor.FieldNameSelectorcreateFieldNameSelector(SolrResourceLoader loader, SolrCore core, FieldMutatingUpdateProcessorFactory.SelectorParams params, FieldMutatingUpdateProcessor.FieldNameSelector defSelector)Utility method that can be used to define a FieldNameSelector using the same types of rules as the FieldMutatingUpdateProcessor init code.static FieldMutatingUpdateProcessor.FieldNameSelectorcreateFieldNameSelector(SolrResourceLoader loader, IndexSchema schema, FieldMutatingUpdateProcessorFactory.SelectorParams params, FieldMutatingUpdateProcessor.FieldNameSelector defSelector)Utility method that can be used to define a FieldNameSelector using the same types of rules as the FieldMutatingUpdateProcessor init code.protected abstract org.apache.solr.common.SolrInputFieldmutate(org.apache.solr.common.SolrInputField src)Method for mutating SolrInputFields associated with fields identified by the FieldNameSelector associated with this processorstatic FieldMutatingUpdateProcessormutator(FieldMutatingUpdateProcessor.FieldNameSelector selector, UpdateRequestProcessor next, Function<org.apache.solr.common.SolrInputField,org.apache.solr.common.SolrInputField> fun)voidprocessAdd(AddUpdateCommand cmd)Callsmutateon any fields identified by the selector before forwarding the command down the chain.static FieldMutatingUpdateProcessor.FieldNameSelectorwrap(FieldMutatingUpdateProcessor.FieldNameSelector includes, FieldMutatingUpdateProcessor.FieldNameSelector excludes)Wraps two FieldNameSelectors such that the FieldNameSelector returned matches all fields specified by the "includes" unless they are matched by "excludes"-
Methods inherited from class org.apache.solr.update.processor.UpdateRequestProcessor
close, doClose, finish, processCommit, processDelete, processMergeIndexes, processRollback
-
-
-
-
Field Detail
-
SELECT_ALL_FIELDS
public static final FieldMutatingUpdateProcessor.FieldNameSelector SELECT_ALL_FIELDS
Singleton indicating all fields should be mutated
-
SELECT_NO_FIELDS
public static final FieldMutatingUpdateProcessor.FieldNameSelector SELECT_NO_FIELDS
Singleton indicating no fields should be mutated
-
-
Constructor Detail
-
FieldMutatingUpdateProcessor
public FieldMutatingUpdateProcessor(FieldMutatingUpdateProcessor.FieldNameSelector selector, UpdateRequestProcessor next)
-
-
Method Detail
-
mutate
protected abstract org.apache.solr.common.SolrInputField mutate(org.apache.solr.common.SolrInputField src)
Method for mutating SolrInputFields associated with fields identified by the FieldNameSelector associated with this processor- Parameters:
src- the SolrInputField to mutate, may be modified in place and returned- Returns:
- the SolrInputField to use in replacing the original (src) value. If null the field will be removed.
-
processAdd
public void processAdd(AddUpdateCommand cmd) throws IOException
Callsmutateon any fields identified by the selector before forwarding the command down the chain. Any SolrExceptions thrown bymutatewill be logged with the Field name, wrapped and re-thrown.- Overrides:
processAddin classUpdateRequestProcessor- Throws:
IOException
-
wrap
public static FieldMutatingUpdateProcessor.FieldNameSelector wrap(FieldMutatingUpdateProcessor.FieldNameSelector includes, FieldMutatingUpdateProcessor.FieldNameSelector excludes)
Wraps two FieldNameSelectors such that the FieldNameSelector returned matches all fields specified by the "includes" unless they are matched by "excludes"- Parameters:
includes- a selector identifying field names that should be selectedexcludes- a selector identifying field names that should be not be selected, even if they are matched by the 'includes' selector- Returns:
- Either a new FieldNameSelector or one of the input selectors if the combination lends itself to optimization.
-
createFieldNameSelector
public static FieldMutatingUpdateProcessor.FieldNameSelector createFieldNameSelector(SolrResourceLoader loader, SolrCore core, FieldMutatingUpdateProcessorFactory.SelectorParams params, FieldMutatingUpdateProcessor.FieldNameSelector defSelector)
Utility method that can be used to define a FieldNameSelector using the same types of rules as the FieldMutatingUpdateProcessor init code. This may be useful for Factories that wish to define default selectors in similar terms to what the configuration would look like.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
createFieldNameSelector
public static FieldMutatingUpdateProcessor.FieldNameSelector createFieldNameSelector(SolrResourceLoader loader, IndexSchema schema, FieldMutatingUpdateProcessorFactory.SelectorParams params, FieldMutatingUpdateProcessor.FieldNameSelector defSelector)
Utility method that can be used to define a FieldNameSelector using the same types of rules as the FieldMutatingUpdateProcessor init code. This may be useful for Factories that wish to define default selectors in similar terms to what the configuration would look like. Usesschemafor checking field existence.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
mutator
public static FieldMutatingUpdateProcessor mutator(FieldMutatingUpdateProcessor.FieldNameSelector selector, UpdateRequestProcessor next, Function<org.apache.solr.common.SolrInputField,org.apache.solr.common.SolrInputField> fun)
-
-