Class CloneFieldUpdateProcessorFactory
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessorFactory
-
- org.apache.solr.update.processor.CloneFieldUpdateProcessorFactory
-
- All Implemented Interfaces:
NamedListInitializedPlugin,SolrCoreAware
public class CloneFieldUpdateProcessorFactory extends UpdateRequestProcessorFactory implements SolrCoreAware
Clones the values found in any matchingsourcefield into a configureddestfield.The
sourcefield(s) can be configured as either:- One or more
<str> - An
<arr>of<str> - A
<lst>containingFieldMutatingUpdateProcessorFactory style selector arguments
The
destfield can be a single<str>containing the literal name of a destination field, or it may be a<lst>specifying a regexpatternand areplacementstring. If the pattern + replacement option is used the pattern will be matched against all fields matched by the source selector, and the replacement string (including any capture groups specified from the pattern) will be evaluated a usingMatcher.replaceAll(String)to generate the literal name of the destination field.If the resolved
destfield already exists in the document, then the values from thesourcefields will be added to it. The "boost" value associated with thedestwill not be changed, and any boost specified on thesourcefields will be ignored. (If thedestfield did not exist prior to this processor, the newly createddestfield will have the default boost of 1.0)In the example below:
- The
categoryfield will be cloned into thecategory_sfield - Both the
authorsandeditorsfields will be cloned into thecontributorsfield - Any field with a name ending in
_price-- except forlist_price-- will be cloned into theall_prices - Any field name beginning with feat and ending in s (i.e. feats or features) will be cloned into a field prefixed with key_ and not ending in s. (i.e. key_feat or key_feature)
<updateRequestProcessorChain name="multiple-clones"> <processor class="solr.CloneFieldUpdateProcessorFactory"> <str name="source">category</str> <str name="dest">category_s</str> </processor> <processor class="solr.CloneFieldUpdateProcessorFactory"> <arr name="source"> <str>authors</str> <str>editors</str> </arr> <str name="dest">contributors</str> </processor> <processor class="solr.CloneFieldUpdateProcessorFactory"> <lst name="source"> <str name="fieldRegex">.*_price$</str> <lst name="exclude"> <str name="fieldName">list_price</str> </lst> </lst> <str name="dest">all_prices</str> </processor> <processor class="solr.processor.CloneFieldUpdateProcessorFactory"> <lst name="source"> <str name="fieldRegex">^feat(.*)s$</str> </lst> <lst name="dest"> <str name="pattern">^feat(.*)s$</str> <str name="replacement">key_feat$1</str> </str> </processor> </updateRequestProcessorChain>In common case situations where you wish to use a single regular expression as both a
fieldRegexselector and a destinationpattern, a "short hand" syntax is support for convinience: Thepatternandreplacementmay be specified at the top level, omittingsourceanddestdeclarations completely, and thepatternwill be used to construct an equivalentsourceselector internally.For example, both of the following configurations are equivalent:
<!-- full syntax --> <processor class="solr.processor.CloneFieldUpdateProcessorFactory"> <lst name="source"> <str name="fieldRegex"^gt;$feat(.*)s$</str> </lst> <lst name="dest"> <str name="pattern">^feat(.*)s$</str> <str name="replacement">key_feat$1</str> </str> </processor> <!-- syntactic sugar syntax --> <processor class="solr.processor.CloneFieldUpdateProcessorFactory"> <str name="pattern">^feat(.*)s$</str> <str name="replacement">key_feat$1</str> </processor>When cloning multiple fields (or a single multivalued field) into a single valued field, one of the
FieldValueSubsetUpdateProcessorFactoryimplementations configured after theCloneFieldUpdateProcessorFactorycan be useful to reduce the list of values down to a single value.- Since:
- 4.0.0
- See Also:
FieldValueSubsetUpdateProcessorFactory
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
UpdateRequestProcessorFactory.RunAlways
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEST_PARAMstatic StringPATTERN_PARAMstatic StringREPLACEMENT_PARAMstatic StringSOURCE_PARAM
-
Constructor Summary
Constructors Constructor Description CloneFieldUpdateProcessorFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateRequestProcessorgetInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)protected FieldMutatingUpdateProcessor.FieldNameSelectorgetSourceSelector()voidinform(SolrCore core)voidinit(org.apache.solr.common.util.NamedList<?> args)initwill be called just once, immediately after creation.
-
-
-
Field Detail
-
SOURCE_PARAM
public static final String SOURCE_PARAM
- See Also:
- Constant Field Values
-
DEST_PARAM
public static final String DEST_PARAM
- See Also:
- Constant Field Values
-
PATTERN_PARAM
public static final String PATTERN_PARAM
- See Also:
- Constant Field Values
-
REPLACEMENT_PARAM
public static final String REPLACEMENT_PARAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
getSourceSelector
protected final FieldMutatingUpdateProcessor.FieldNameSelector getSourceSelector()
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugininitwill be called just once, immediately after creation.Source of the initialization arguments will typically be solrconfig.xml, but will ultimately depends on the plugin itself
- Specified by:
initin interfaceNamedListInitializedPlugin- Parameters:
args- non-null list of initialization parameters (may be empty)
-
inform
public void inform(SolrCore core)
- Specified by:
informin interfaceSolrCoreAware
-
getInstance
public final UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
- Specified by:
getInstancein classUpdateRequestProcessorFactory
-
-