public class CloneFieldUpdateProcessorFactory extends UpdateRequestProcessorFactory implements SolrCoreAware
source
field into
a configured dest
field.
The source
field(s) can be configured as either:
<str>
<arr>
of <str>
<lst>
containing FieldMutatingUpdateProcessorFactory style selector arguments
The dest
field can be a single <str>
containing the literal name of a destination field, or it may be a <lst>
specifying a
regex pattern
and a replacement
string. 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 using
Matcher.replaceAll(String)
to generate the literal name of the destination field.
If the resolved dest
field already exists in the document, then the
values from the source
fields will be added to it. The
"boost" value associated with the dest
will not be changed,
and any boost specified on the source
fields will be ignored.
(If the dest
field did not exist prior to this processor, the
newly created dest
field will have the default boost of 1.0)
In the example below:
category
field will be cloned into the category_s
fieldauthors
and editors
fields will be cloned into the
contributors
field
_price
-- except for
list_price
-- will be cloned into the all_prices
<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
fieldRegex
selector and a destination pattern
, a "short hand" syntax
is support for convinience: The pattern
and replacement
may be specified
at the top level, omitting source
and dest
declarations completely, and
the pattern
will be used to construct an equivalent source
selector 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
FieldValueSubsetUpdateProcessorFactory
implementations configured after the
CloneFieldUpdateProcessorFactory
can be useful to reduce the list of values down to a
single value.
FieldValueSubsetUpdateProcessorFactory
UpdateRequestProcessorFactory.RunAlways
Modifier and Type | Field and Description |
---|---|
static String |
DEST_PARAM |
static String |
PATTERN_PARAM |
static String |
REPLACEMENT_PARAM |
static String |
SOURCE_PARAM |
Constructor and Description |
---|
CloneFieldUpdateProcessorFactory() |
Modifier and Type | Method and Description |
---|---|
UpdateRequestProcessor |
getInstance(SolrQueryRequest req,
SolrQueryResponse rsp,
UpdateRequestProcessor next) |
protected FieldMutatingUpdateProcessor.FieldNameSelector |
getSourceSelector() |
void |
inform(SolrCore core) |
void |
init(NamedList args) |
public static final String SOURCE_PARAM
public static final String DEST_PARAM
public static final String PATTERN_PARAM
public static final String REPLACEMENT_PARAM
protected final FieldMutatingUpdateProcessor.FieldNameSelector getSourceSelector()
public void init(NamedList args)
init
in interface NamedListInitializedPlugin
init
in class UpdateRequestProcessorFactory
public void inform(SolrCore core)
inform
in interface SolrCoreAware
public final UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
getInstance
in class UpdateRequestProcessorFactory
Copyright © 2000-2019 Apache Software Foundation. All Rights Reserved.