Class PreAnalyzedUpdateProcessorFactory
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessorFactory
-
- org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
-
- org.apache.solr.update.processor.PreAnalyzedUpdateProcessorFactory
-
- All Implemented Interfaces:
NamedListInitializedPlugin
,SolrCoreAware
public class PreAnalyzedUpdateProcessorFactory extends FieldMutatingUpdateProcessorFactory
An update processor that parses configured fields of any document being added usingPreAnalyzedField
with the configured format parser.Fields are specified using the same patterns as in
FieldMutatingUpdateProcessorFactory
. They are then checked whether they follow a pre-analyzed format defined byparser
. Valid fields are then parsed. The originalSchemaField
is used for the initial creation ofIndexableField
, which is then modified to add the results from parsing (token stream value and/or string value) and then it will be directly added to the final LuceneDocument
to be indexed.Fields that are declared in the patterns list but are not present in the current schema will be removed from the input document.
Implementation details
This update processor uses
PreAnalyzedField.PreAnalyzedParser
to parse the original field content (interpreted as a string value), and thus obtain the stored part and the token stream part. Then it creates the "template"Field
-s using the originalSchemaField.createFields(Object)
as declared in the current schema. Finally it sets the pre-analyzed parts if available (string value and the token stream value) on the first field of these "template" fields. If the declared field type does not support stored or indexed parts then such parts are silently discarded. Finally the updated "template"Field
-s are added to the resultingSolrInputField
, and the original value of that field is removed.Example configuration
In the example configuration below there are two update chains, one that uses the "simple" parser (
SimplePreAnalyzedParser
) and one that uses the "json" parser (JsonPreAnalyzedParser
). Field "nonexistent" will be removed from input documents if not present in the schema. Other fields will be analyzed and if valid they will be converted toIndexableField
-s or if they are not in a valid format that can be parsed with the selected parser they will be passed as-is. Assuming thatssto
field is stored but not indexed, andsind
field is indexed but not stored: ifssto
input value contains the indexed part then this part will be discarded and only the stored value part will be retained. Similarly, ifsind
input value contains the stored part then it will be discarded and only the token stream part will be retained.<updateRequestProcessorChain name="pre-analyzed-simple"> <processor class="solr.PreAnalyzedUpdateProcessorFactory"> <str name="fieldName">title</str> <str name="fieldName">nonexistent</str> <str name="fieldName">ssto</str> <str name="fieldName">sind</str> <str name="parser">simple</str> </processor> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain> <updateRequestProcessorChain name="pre-analyzed-json"> <processor class="solr.PreAnalyzedUpdateProcessorFactory"> <str name="fieldName">title</str> <str name="fieldName">nonexistent</str> <str name="fieldName">ssto</str> <str name="fieldName">sind</str> <str name="parser">json</str> </processor> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain>
- Since:
- 4.3.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
FieldMutatingUpdateProcessorFactory.SelectorParams
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
UpdateRequestProcessorFactory.RunAlways
-
-
Constructor Summary
Constructors Constructor Description PreAnalyzedUpdateProcessorFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateRequestProcessor
getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
void
inform(SolrCore core)
void
init(org.apache.solr.common.util.NamedList<?> args)
Handles common initialization related to source fields for constructing the FieldNameSelector to be used.-
Methods inherited from class org.apache.solr.update.processor.FieldMutatingUpdateProcessorFactory
getDefaultSelector, getSelector, parseSelectorExclusionParams, parseSelectorParams
-
-
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from class:FieldMutatingUpdateProcessorFactory
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 interfaceNamedListInitializedPlugin
- Overrides:
init
in classFieldMutatingUpdateProcessorFactory
- Parameters:
args
- non-null list of initialization parameters (may be empty)
-
getInstance
public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
- Specified by:
getInstance
in classUpdateRequestProcessorFactory
-
inform
public void inform(SolrCore core)
- Specified by:
inform
in interfaceSolrCoreAware
- Overrides:
inform
in classFieldMutatingUpdateProcessorFactory
-
-