Class AtomicUpdateDocumentMerger

  • public class AtomicUpdateDocumentMerger
    extends Object
    WARNING: This API is experimental and might change in incompatible ways in the next release.
    • Constructor Detail

      • AtomicUpdateDocumentMerger

        public AtomicUpdateDocumentMerger​(SolrQueryRequest queryReq)
    • Method Detail

      • isAtomicUpdate

        public static boolean isAtomicUpdate​(AddUpdateCommand cmd)
        Utility method that examines the SolrInputDocument in an AddUpdateCommand and returns true if the documents contains atomic update instructions.
      • merge

        public SolrInputDocument merge​(SolrInputDocument sdoc,
                                       SolrInputDocument toDoc)
        Merges the fromDoc into the toDoc using the atomic update syntax. This method will look for a nested document (possibly toDoc itself) with an equal ID, and merge into that one.
        sdoc - the doc containing update instructions
        toDoc - the target doc (possibly nested) before the update (will be modified in-place)
        toDoc with modifications; never null
      • isSupportedFieldForInPlaceUpdate

        public static boolean isSupportedFieldForInPlaceUpdate​(SchemaField schemaField)
        Given a schema field, return whether or not such a field is supported for an in-place update. Note: If an update command has updates to only supported fields (and _version_ is also supported), only then is such an update command executed as an in-place update.
      • computeInPlaceUpdatableFields

        public static Set<String> computeInPlaceUpdatableFields​(AddUpdateCommand cmd)
                                                         throws IOException
        Given an add update command, compute a list of fields that can be updated in-place. If there is even a single field in the update that cannot be updated in-place, the entire update cannot be executed in-place (and empty set will be returned in that case).
        Return a set of fields that can be in-place updated.
      • isDerivedFromDoc

        public static boolean isDerivedFromDoc​(SolrInputDocument fullDoc,
                                               SolrInputDocument partialDoc)
        fullDoc - the full doc to be compared against
        partialDoc - the sub document to be tested
        whether partialDoc is derived from fullDoc
      • doInPlaceUpdateMerge

        public boolean doInPlaceUpdateMerge​(AddUpdateCommand cmd,
                                            Set<String> updatedFields)
                                     throws IOException
        Given an AddUpdateCommand containing update operations (e.g. set, inc), merge and resolve the operations into a partial document that can be used for indexing the in-place updates. The AddUpdateCommand is modified to contain the partial document (instead of the original document which contained the update operations) and also the prevVersion that this in-place update depends on. Note: updatedFields passed into the method can be changed, i.e. the version field can be added to the set.
        If in-place update cannot succeed, e.g. if the old document is deleted recently, then false is returned. A false return indicates that this update can be re-tried as a full atomic update. Returns true if the in-place update succeeds.