org.apache.solr.update.processor

## Class FieldMutatingUpdateProcessor

- java.lang.Object
- - org.apache.solr.update.processor.UpdateRequestProcessor
  - - org.apache.solr.update.processor.FieldMutatingUpdateProcessor

- 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.

  See Also:
    `FieldMutatingUpdateProcessorFactory`, `FieldValueMutatingUpdateProcessor`, `FieldMutatingUpdateProcessor.FieldNameSelector`

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `FieldMutatingUpdateProcessor.FieldNameSelector` Interface for identifying which fields should be mutated

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FieldMutatingUpdateProcessor.FieldNameSelector` | `SELECT_ALL_FIELDS` Singleton indicating all fields should be mutated
    `static FieldMutatingUpdateProcessor.FieldNameSelector` | `SELECT_NO_FIELDS` Singleton indicating no fields should be mutated

    - ### Fields inherited from class org.apache.solr.update.processor.UpdateRequestProcessor

      `next`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FieldMutatingUpdateProcessor(FieldMutatingUpdateProcessor.FieldNameSelector selector, UpdateRequestProcessor next)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `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.
    `protected abstract SolrInputField` | `mutate(SolrInputField src)` Method for mutating SolrInputFields associated with fields identified by the FieldNameSelector associated with this processor
    `static FieldMutatingUpdateProcessor` | `mutator(FieldMutatingUpdateProcessor.FieldNameSelector selector, UpdateRequestProcessor next, Function<SolrInputField,SolrInputField> fun)`
    `void` | `processAdd(AddUpdateCommand cmd)` Calls `mutate` on any fields identified by the selector before forwarding the command down the chain.
    `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"

    - ### Methods inherited from class org.apache.solr.update.processor.UpdateRequestProcessor

      `finish, processCommit, processDelete, processMergeIndexes, processRollback`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 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 SolrInputField mutate(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

      Calls `mutate` on any fields identified by the selector before forwarding the command down the chain. Any SolrExceptions thrown by `mutate` will be logged with the Field name, wrapped and re-thrown.
      Overrides:
        `processAdd` in class `UpdateRequestProcessor`
      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 selected
        `excludes` - 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 selecors 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. Uses `schema` for 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<SolrInputField,SolrInputField> fun)

Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.