Class IndexingCommand

java.lang.Object
org.nuxeo.elasticsearch.commands.IndexingCommand
All Implemented Interfaces:
Serializable

public class IndexingCommand extends Object implements Serializable
Holds information about what type of indexing operation must be processed. IndexingCommands are create "on the fly" via a Synchronous event listener and at post commit time the system will merge the commands and execute worker to process them.
See Also:
  • Field Details

    • PREFIX

      public static final String PREFIX
      See Also:
    • id

      protected String id
    • type

      protected IndexingCommand.Type type
    • sync

      protected boolean sync
    • recurse

      protected boolean recurse
    • targetDocumentId

      protected String targetDocumentId
    • path

      protected String path
    • repositoryName

      protected String repositoryName
    • schemas

      protected List<String> schemas
    • order

      protected long order
    • seq

      protected static transient AtomicLong seq
  • Constructor Details

    • IndexingCommand

      protected IndexingCommand()
    • IndexingCommand

      public IndexingCommand(DocumentModel document, IndexingCommand.Type commandType, boolean sync, boolean recurse)
      Create an indexing command
      Parameters:
      document - the target document
      commandType - the type of command
      sync - if true the command will be processed on the same thread after transaction completion and the Elasticsearch index will be refresh
      recurse - the command affect the document and all its descendants
  • Method Details

    • getValidTargetDocument

      protected DocumentModel getValidTargetDocument(DocumentModel target)
    • attach

      public void attach(CoreSession session)
    • getTargetDocument

      public DocumentModel getTargetDocument()
      Return the document or null if it does not exists anymore.
      Throws:
      IllegalStateException - if there is no session attached
    • getRepositoryName

      public String getRepositoryName()
    • merge

      public boolean merge(IndexingCommand other)
      Returns:
      true if merged
    • merge

      protected void merge(boolean sync, boolean recurse)
    • canBeMerged

      protected boolean canBeMerged(IndexingCommand other)
    • isSync

      public boolean isSync()
    • isRecurse

      public boolean isRecurse()
    • getType

      public IndexingCommand.Type getType()
    • toJSON

      public String toJSON() throws IOException
      Throws:
      IOException
    • toJSON

      public void toJSON(com.fasterxml.jackson.core.JsonGenerator jsonGen) throws IOException
      Throws:
      IOException
    • fromJSON

      public static IndexingCommand fromJSON(String json)
      Create a command from a JSON string.
      Throws:
      IllegalArgumentException - if json is invalid or command is invalid
    • fromJSON

      public static IndexingCommand fromJSON(com.fasterxml.jackson.databind.JsonNode jsonNode)
    • getId

      public String getId()
    • getTargetDocumentId

      public String getTargetDocumentId()
    • clone

      public IndexingCommand clone(DocumentModel newDoc)
    • getSchemas

      public String[] getSchemas()
    • addSchemas

      public void addSchemas(String schema)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • makeSync

      public void makeSync()
      Try to make the command synchronous. Recurse command will stay in async for update.
    • getOrder

      public long getOrder()
    • setOrder

      public void setOrder(long order)