Class DocBasedVersionConstraintsProcessor

java.lang.Object
org.apache.solr.update.processor.UpdateRequestProcessor
org.apache.solr.update.processor.DocBasedVersionConstraintsProcessor
All Implemented Interfaces:
Closeable, AutoCloseable

public class DocBasedVersionConstraintsProcessor extends UpdateRequestProcessor
  • Constructor Details

    • DocBasedVersionConstraintsProcessor

      public DocBasedVersionConstraintsProcessor(List<String> versionFields, boolean ignoreOldUpdates, List<String> deleteVersionParamNames, boolean supportMissingVersionOnOldDocs, boolean useFieldCache, org.apache.solr.common.util.NamedList<Object> tombstoneConfig, SolrQueryRequest req, UpdateRequestProcessor next)
  • Method Details

    • versionInUpdateIsAcceptable

      protected boolean versionInUpdateIsAcceptable(Object[] newUserVersions, Object[] oldUserVersions)
      Returns whether or not the versions in the command are acceptable to be indexed. If the instance is set to ignoreOldUpdates==false, it will throw a SolrException with CONFLICT in the event the version is not acceptable rather than return false.
      Parameters:
      newUserVersions - New versions in update request
      oldUserVersions - Old versions currently in solr index
      Returns:
      True if acceptable, false if not (or will throw exception)
    • newUpdateComparePasses

      protected <T extends Comparable<? super T>> boolean newUpdateComparePasses(T newUserVersion, T oldUserVersion, String userVersionFieldName)
      Given two comparable user versions, returns whether the new version is acceptable to replace the old version.
      Parameters:
      newUserVersion - User-specified version on the new version of the document
      oldUserVersion - User-specified version on the old version of the document
      userVersionFieldName - Field name of the user versions being compared
      Returns:
      True if acceptable, false if not.
    • processAdd

      public void processAdd(AddUpdateCommand cmd) throws IOException
      Overrides:
      processAdd in class UpdateRequestProcessor
      Throws:
      IOException
    • processDelete

      public void processDelete(DeleteUpdateCommand cmd) throws IOException
      Overrides:
      processDelete in class UpdateRequestProcessor
      Throws:
      IOException
    • createTombstoneDocument

      protected org.apache.solr.common.SolrInputDocument createTombstoneDocument(IndexSchema schema, String id, String[] versionFieldNames, String[] deleteParamValues, org.apache.solr.common.util.NamedList<Object> tombstoneConfig)
      Creates a tombstone document, that will be used to update a document that's being deleted by ID. The returned document will contain:
      • uniqueKey
      • versions (All the fields configured as in the versionField parameter)
      • All the fields set in the tombstoneConfig parameter
      Note that if the schema contains required fields (other than version fields or uniqueKey), they should be populated by the tombstoneConfig, otherwise this tombstone will fail when indexing (and consequently the delete will fail). Alternatively, required fields must be populated by some other means (like DocBasedVersionConstraintsProcessorFactory or similar)