Class AbstractSolrIndexUpdateCommandHandlerImpl

java.lang.Object
org.broadleafcommerce.core.search.service.solr.indexer.AbstractSolrIndexUpdateCommandHandlerImpl
All Implemented Interfaces:
SolrIndexUpdateCommandHandler
Direct Known Subclasses:
CatalogSolrIndexUpdateCommandHandlerImpl

public abstract class AbstractSolrIndexUpdateCommandHandlerImpl extends Object implements SolrIndexUpdateCommandHandler
Component to provide basic functionality around handling SolrUpdateCommands.
Author:
Kelly Tisdell
  • Constructor Details

    • AbstractSolrIndexUpdateCommandHandlerImpl

      public AbstractSolrIndexUpdateCommandHandlerImpl(String commandGroup)
  • Method Details

    • getCommandGroup

      public String getCommandGroup()
      Description copied from interface: SolrIndexUpdateCommandHandler
      Command group or identifier for which this component can respond. E.g. "catalog". Components that use the same command group operate on the same Solr collections / aliases (indexes).

      Multiple invocations of this method must return the same result.

      Specified by:
      getCommandGroup in interface SolrIndexUpdateCommandHandler
      Returns:
    • executeCommandInternal

      protected void executeCommandInternal(IncrementalUpdateCommand command) throws org.broadleafcommerce.common.exception.ServiceException
      By default, this will update the foreground collection. Deletes, if available, will be applied first. Then, updates. This should be considered an autonomous method. Do not use this to make incremental updates within the scope of a larger update process because this will apply commits, by default.
      Parameters:
      command -
      Throws:
      org.broadleafcommerce.common.exception.ServiceException
    • executeCommandInternal

      protected void executeCommandInternal(IncrementalUpdateCommand command, String collectionName) throws org.broadleafcommerce.common.exception.ServiceException
      This will apply updates in the specified collection, and will commit, when finished, if no errors occur. Deletes, if available, will be applied first. Then, updates. This should be considered an autonomous method. Do not use this to make incremental updates within the scope of a larger update process because this will apply commits, by default.
      Parameters:
      command -
      collectionName -
      Throws:
      org.broadleafcommerce.common.exception.ServiceException
    • executeCommandInternalNoDefaultCommandType

      protected void executeCommandInternalNoDefaultCommandType(SolrUpdateCommand command) throws org.broadleafcommerce.common.exception.ServiceException
      Hook point for implementors to handle new command types.
      Parameters:
      command -
      Throws:
      Exception
      org.broadleafcommerce.common.exception.ServiceException
    • commit

      protected void commit(String collectionName, boolean waitFlush, boolean waitSearcher, boolean softCommit) throws Exception
      Issues a global commit command to Solr. Take care as anyone can issue a commit and since it's global it affects all updates. It is recommended that you off Solr's autoCommit and autoSoftCommit features.
      Parameters:
      collectionName -
      waitFlush -
      waitSearcher -
      softCommit -
      Throws:
      Exception
    • rollback

      protected void rollback(String collectionName) throws Exception
      Issues a global rollback of all items that have not yet been committed. Take care as anyone can issue a commit and since it's global it affects all updates. It is recommended that you off Solr's autoCommit and autoSoftCommit features.
      Parameters:
      collectionName -
      Throws:
      Exception
    • addDocument

      protected void addDocument(String collection, org.apache.solr.common.SolrInputDocument doc) throws Exception
      Adds the document to the specified collection but does not issue a commit.
      Parameters:
      collection -
      doc -
      Throws:
      Exception
    • addDocuments

      protected void addDocuments(String collection, List<org.apache.solr.common.SolrInputDocument> docs) throws Exception
      Adds the documents to the specified collection but does not issue a commit.
      Parameters:
      collection -
      docs -
      Throws:
      Exception
    • deleteByQuery

      protected void deleteByQuery(String collection, String query) throws Exception
      Deletes items for the provided query. This does not issue a commit.
      Parameters:
      collection -
      query -
      Throws:
      Exception
    • deleteByQueries

      protected void deleteByQueries(String collection, List<String> queries) throws Exception
      Deletes items for the provided queries. This does not issue a commit.
      Parameters:
      collection -
      queries -
      Throws:
      Exception
    • deleteByIds

      protected void deleteByIds(String collection, List<String> ids) throws Exception
      Deletes items by ids. This does not issue a commit.
      Parameters:
      collection -
      ids -
      Throws:
      IOException
      org.apache.solr.client.solrj.SolrServerException
      Exception
    • getForegroundCollectionName

      public String getForegroundCollectionName()
      Description copied from interface: SolrIndexUpdateCommandHandler
      The "live" or customer facing collection (index) name or alias. This should return a non-null, non-empty string. Every invocation should return the same value. (e.g. "catalog").
      Specified by:
      getForegroundCollectionName in interface SolrIndexUpdateCommandHandler
      Returns:
    • getBackgroundCollectionName

      public String getBackgroundCollectionName()
      Description copied from interface: SolrIndexUpdateCommandHandler
      The background or "offline" collection (index) name or alias. This should return a non-null, non-empty string. Every invocation should return the same value. (e.g. "catalogs_reindex").
      Specified by:
      getBackgroundCollectionName in interface SolrIndexUpdateCommandHandler
      Returns:
    • getSolrConfiguration

      protected abstract SolrConfiguration getSolrConfiguration()