Class UUIDUpdateProcessorFactory
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessorFactory
-
- org.apache.solr.update.processor.UUIDUpdateProcessorFactory
-
- All Implemented Interfaces:
NamedListInitializedPlugin
public class UUIDUpdateProcessorFactory extends UpdateRequestProcessorFactory
An update processor that adds a newly generatedUUID
value to any document being added that does not already have a value in the specified field.In the example configuration below, if a document does not contain a value in the
id
field, a newUUID
will be generated and added as the value of that field.
<processor class="solr.UUIDUpdateProcessorFactory"> <str name="fieldName">id</str> </processor>
You can also invoke the processor with request handler param(s) as
uuid.fieldname
withprocessor=uuid
curl -X POST -H Content-Type: application/json http://localhost:8983/solr/test/update/json/docs?processor=uuid;ampersand;uuid.fieldName=id;ampersand;commit=true --data-binary {"id":"1","title": "titleA"}NOTE: The param(s) provided in request handler will override / supersede processor's config.
If field name is omitted in processor configuration and not provided in request handler param(s), then
IndexSchema.getUniqueKeyField()
is used as field and a newUUID
will be generated and added as the value of that field. The field type of the uniqueKeyField must be anything which accepts a string or UUID value.- Since:
- 4.0.0
- See Also:
UUID
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
UpdateRequestProcessorFactory.RunAlways
-
-
Constructor Summary
Constructors Constructor Description UUIDUpdateProcessorFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description UpdateRequestProcessor
getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
void
init(org.apache.solr.common.util.NamedList<?> args)
init
will be called just once, immediately after creation.
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
fieldName
protected String fieldName
-
-
Method Detail
-
init
public void init(org.apache.solr.common.util.NamedList<?> args)
Description copied from interface:NamedListInitializedPlugin
init
will 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
- 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
-
-