org.apache.solr.update.processor
Class AddSchemaFieldsUpdateProcessorFactory

java.lang.Object
  extended by org.apache.solr.update.processor.UpdateRequestProcessorFactory
      extended by org.apache.solr.update.processor.AddSchemaFieldsUpdateProcessorFactory
All Implemented Interfaces:
NamedListInitializedPlugin, SolrCoreAware

public class AddSchemaFieldsUpdateProcessorFactory
extends UpdateRequestProcessorFactory
implements SolrCoreAware

This processor will dynamically add fields to the schema if an input document contains one or more fields that don't match any field or dynamic field in the schema.

By default, this processor selects all fields that don't match a schema field or dynamic field. The "fieldName" and "fieldRegex" selectors may be specified to further restrict the selected fields, but the other selectors ("typeName", "typeClass", and "fieldNameMatchesSchemaField") may not be specified.

This processor is configured to map from each field's values' class(es) to the schema field type that will be used when adding the new field to the schema. All new fields are then added to the schema in a single batch. If schema addition fails for any field, addition is re-attempted only for those that don’t match any schema field. This process is repeated, either until all new fields are successfully added, or until there are no new fields (presumably because the fields that were new when this processor started its work were subsequently added by a different update request, possibly on a different node).

This processor takes as configuration a sequence of zero or more "typeMapping"-s from one or more "valueClass"-s, specified as either an <arr> of <str>, or multiple <str> with the same name, to an existing schema "fieldType".

If more than one "valueClass" is specified in a "typeMapping", field values with any of the specified "valueClass"-s will be mapped to the specified target "fieldType". The "typeMapping"-s are attempted in the specified order; if a field value's class is not specified in a "valueClass", the next "typeMapping" is attempted. If no "typeMapping" succeeds, then the specified "defaultFieldType" is used.

Example configuration:

 <processor class="solr.AddSchemaFieldsUpdateProcessorFactory">
   <str name="defaultFieldType">text_general</str>
   <lst name="typeMapping">
     <str name="valueClass">Boolean</str>
     <str name="fieldType">boolean</str>
   </lst>
   <lst name="typeMapping">
     <str name="valueClass">Integer</str>
     <str name="fieldType">tint</str>
   </lst>
   <lst name="typeMapping">
     <str name="valueClass">Float</str>
     <str name="fieldType">tfloat</str>
   </lst>
   <lst name="typeMapping">
     <str name="valueClass">Date</str>
     <str name="fieldType">tdate</str>
   </lst>
   <lst name="typeMapping">
     <str name="valueClass">Long</str>
     <str name="valueClass">Integer</str>
     <str name="fieldType">tlong</str>
   </lst>
   <lst name="typeMapping">
     <arr name="valueClass">
       <str>Double</str>
       <str>Float</str>
     </arr>
     <str name="fieldType">tdouble</str>
   </lst>
 </processor>


Field Summary
static org.slf4j.Logger log
           
 
Constructor Summary
AddSchemaFieldsUpdateProcessorFactory()
           
 
Method Summary
 UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
           
protected  FieldMutatingUpdateProcessor.FieldNameSelector getSelector()
           
 void inform(SolrCore core)
           
 void init(NamedList args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.slf4j.Logger log
Constructor Detail

AddSchemaFieldsUpdateProcessorFactory

public AddSchemaFieldsUpdateProcessorFactory()
Method Detail

getSelector

protected final FieldMutatingUpdateProcessor.FieldNameSelector getSelector()

getInstance

public UpdateRequestProcessor getInstance(SolrQueryRequest req,
                                          SolrQueryResponse rsp,
                                          UpdateRequestProcessor next)
Specified by:
getInstance in class UpdateRequestProcessorFactory

init

public void init(NamedList args)
Specified by:
init in interface NamedListInitializedPlugin
Overrides:
init in class UpdateRequestProcessorFactory

inform

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


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