Package org.apache.solr.update.processor
Class DocBasedVersionConstraintsProcessorFactory
- java.lang.Object
-
- org.apache.solr.update.processor.UpdateRequestProcessorFactory
-
- org.apache.solr.update.processor.DocBasedVersionConstraintsProcessorFactory
-
- All Implemented Interfaces:
UpdateRequestProcessorFactory.RunAlways
,NamedListInitializedPlugin
,SolrCoreAware
public class DocBasedVersionConstraintsProcessorFactory extends UpdateRequestProcessorFactory implements SolrCoreAware, UpdateRequestProcessorFactory.RunAlways
This Factory generates an UpdateProcessor that helps to enforce Version constraints on documents based on per-document version numbers using a configuredversionField
, a comma-delimited list of fields to check for version numbers. It should be configured on the "default" update processor somewhere before the DistributedUpdateProcessorFactory. As an example, see the solrconfig.xml that the tests use: solr/core/src/test-files/solr/collection1/conf/solrconfig-externalversionconstraint.xmlWhen documents are added through this processor, if a document with the same unique key already exists in the collection, then the values within the fields as specified by the comma-delimited
versionField
property are checked, and if in the existing document the values for all fields are not less than the field values in the new document, then the new document is rejected with a 409 Version Conflict error.In addition to the mandatory
versionField
init param, two additional optional init params affect the behavior of this factory:deleteVersionParam
- This string parameter controls whether this processor will intercept and inspect Delete By Id commands in addition to adding documents. If specified, then the value will specify the name(s) of the request parameter(s) which becomes mandatory for all Delete By Id commands. LikeversionField
,deleteVersionParam
is comma-delimited. For each of the params given, it specifies the document version associated with the delete, where the index matchesversionField
. For example, ifversionField
was set to 'a,b' anddeleteVersionParam
was set to 'p1,p2', p1 should give the version for field 'a' and p2 should give the version for field 'b'. If the versions specified using these params are not greater then the value in theversionField
for any existing document, then the delete will fail with a 409 Version Conflict error. When using this param, Any Delete By Id command with a high enough document version number to succeed will be internally converted into an Add Document command that replaces the existing document with a new one which is empty except for the Unique Key and fields corresponding to the fields listed inversionField
to keeping a record of the deleted version so future Add Document commands will fail if their "new" version is not high enough.ignoreOldUpdates
- This boolean parameter defaults tofalse
, but if set totrue
causes any update with a document version that is not great enough to be silently ignored (and return a status 200 to the client) instead of generating a 409 Version Conflict error.supportMissingVersionOnOldDocs
- This boolean parameter defaults tofalse
, but if set totrue
allows any documents written *before* this feature is enabled and which are missing the versionField to be overwritten.tombstoneConfig
- a list of field names to values to add to the created tombstone document. In general is not a good idea to populate tombsone documents with anything other than the minimum required fields so that it doean't match queries
- Since:
- 4.6.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.solr.update.processor.UpdateRequestProcessorFactory
UpdateRequestProcessorFactory.RunAlways
-
-
Constructor Summary
Constructors Constructor Description DocBasedVersionConstraintsProcessorFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canCreateTombstoneDocument(IndexSchema schema)
Validates that the schema would allow tombstones to be created by DocBasedVersionConstraintsProcessor by checking if the required fields are of known typesUpdateRequestProcessor
getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next)
void
inform(SolrCore core)
void
init(org.apache.solr.common.util.NamedList<?> args)
init
will be called just once, immediately after creation.
-
-
-
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
- Specified by:
init
in interfaceNamedListInitializedPlugin
- 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
-
canCreateTombstoneDocument
protected boolean canCreateTombstoneDocument(IndexSchema schema)
Validates that the schema would allow tombstones to be created by DocBasedVersionConstraintsProcessor by checking if the required fields are of known types
-
-