org.apache.solr.update.processor
Class FieldMutatingUpdateProcessorFactory

java.lang.Object
  extended by org.apache.solr.update.processor.UpdateRequestProcessorFactory
      extended by org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
All Implemented Interfaces:
NamedListInitializedPlugin, SolrCoreAware
Direct Known Subclasses:
ConcatFieldUpdateProcessorFactory, CountFieldValuesUpdateProcessorFactory, FieldLengthUpdateProcessorFactory, FieldValueSubsetUpdateProcessorFactory, HTMLStripFieldUpdateProcessorFactory, IgnoreFieldUpdateProcessorFactory, ParseBooleanFieldUpdateProcessorFactory, ParseDateFieldUpdateProcessorFactory, ParseNumericFieldUpdateProcessorFactory, PreAnalyzedUpdateProcessorFactory, RegexReplaceProcessorFactory, RemoveBlankFieldUpdateProcessorFactory, TrimFieldUpdateProcessorFactory, TruncateFieldUpdateProcessorFactory

public abstract class FieldMutatingUpdateProcessorFactory
extends UpdateRequestProcessorFactory
implements SolrCoreAware

Base class for implementing Factories for FieldMutatingUpdateProcessors and FieldValueMutatingUpdateProcessors.

This class provides all of the plumbing for configuring the FieldNameSelector using the following init params to specify selection criteria...

Each criteria can specified as either an <arr> of <str>, or multiple <str> with the same name. When multiple criteria of a single type exist, fields must match at least one to be selected. If more then one type of criteria exist, fields must match at least one of each to be selected.

The following additional selector may be specified as a <bool> - when specified as false, only fields that do not match a schema field/dynamic field are selected; when specified as true, only fields that do match a schema field/dynamic field are selected:

One or more excludes <lst> params may also be specified, containing any of the above criteria, identifying fields to be excluded from seelction even if they match the selection criteria. As with the main selection critiera a field must match all of criteria in a single exclusion in order to be excluded, but multiple exclusions may be specified to get an OR behavior

In the ExampleFieldMutatingUpdateProcessorFactory configured below, fields will be mutated if the name starts with "foo" or "bar"; unless the field name contains the substring "SKIP" or the fieldType is (or subclasses) DateField. Meaning a field named "foo_SKIP" is guaranteed not to be selected, but a field named "bar_smith" that uses StrField will be selected.

 <processor class="solr.ExampleFieldMutatingUpdateProcessorFactory">
   <str name="fieldRegex">foo.*</str>
   <str name="fieldRegex">bar.*</str>
   <!-- each set of exclusions is checked independently -->
   <lst name="exclude">
     <str name="fieldRegex">.*SKIP.*</str>
   </lst>
   <lst name="exclude">
     <str name="typeClass">solr.DateField</str>
   </lst>
 </processor>

Subclasses define the default selection behavior to be applied if no criteria is configured by the user. User configured "exclude" criteria will be applied to the subclass defined default selector.

See Also:
FieldMutatingUpdateProcessor, FieldValueMutatingUpdateProcessor, FieldMutatingUpdateProcessor.FieldNameSelector

Nested Class Summary
static class FieldMutatingUpdateProcessorFactory.SelectorParams
           
 
Constructor Summary
FieldMutatingUpdateProcessorFactory()
           
 
Method Summary
static Boolean getBooleanArg(NamedList args, String key)
          Removes the first instance of the key from NamedList, returning the Boolean that key referred to, or null if the key is not specified.
protected  FieldMutatingUpdateProcessor.FieldNameSelector getDefaultSelector(SolrCore core)
          Defines the default selection behavior when the user has not configured any specific criteria for selecting fields.
protected  FieldMutatingUpdateProcessor.FieldNameSelector getSelector()
           
 void inform(SolrCore core)
           
 void init(NamedList args)
          Handles common initialization related to source fields for constructing the FieldNameSelector to be used.
static Collection<String> oneOrMany(NamedList args, String key)
          Removes all instance of the key from NamedList, returning the Set of Strings that key referred to.
static Collection<FieldMutatingUpdateProcessorFactory.SelectorParams> parseSelectorExclusionParams(NamedList args)
           
static FieldMutatingUpdateProcessorFactory.SelectorParams parseSelectorParams(NamedList args)
           
 
Methods inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FieldMutatingUpdateProcessorFactory

public FieldMutatingUpdateProcessorFactory()
Method Detail

getSelector

protected final FieldMutatingUpdateProcessor.FieldNameSelector getSelector()

parseSelectorParams

public static FieldMutatingUpdateProcessorFactory.SelectorParams parseSelectorParams(NamedList args)

parseSelectorExclusionParams

public static Collection<FieldMutatingUpdateProcessorFactory.SelectorParams> parseSelectorExclusionParams(NamedList args)

init

public void init(NamedList args)
Handles common initialization related to source fields for constructing the FieldNameSelector to be used. Will error if any unexpected init args are found, so subclasses should remove any subclass-specific init args before calling this method.

Specified by:
init in interface NamedListInitializedPlugin
Overrides:
init in class UpdateRequestProcessorFactory

inform

public void inform(SolrCore core)
Specified by:
inform in interface SolrCoreAware

getDefaultSelector

protected FieldMutatingUpdateProcessor.FieldNameSelector getDefaultSelector(SolrCore core)
Defines the default selection behavior when the user has not configured any specific criteria for selecting fields. The Default implementation matches all fields, and should be overridden by subclasses as needed.

See Also:
FieldMutatingUpdateProcessor.SELECT_ALL_FIELDS

oneOrMany

public static Collection<String> oneOrMany(NamedList args,
                                           String key)
Removes all instance of the key from NamedList, returning the Set of Strings that key referred to. Throws an error if the key didn't refer to one or more strings (or arrays of strings)

Throws:
SolrException - invalid arr/str structure.

getBooleanArg

public static Boolean getBooleanArg(NamedList args,
                                    String key)
Removes the first instance of the key from NamedList, returning the Boolean that key referred to, or null if the key is not specified.

Throws:
SolrException - invalid type or structure


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