Interface SolrIndexProvider

All Superinterfaces:
com.broadleafcommerce.search.provider.ReindexProvider<org.apache.solr.common.SolrInputDocument>
All Known Implementing Classes:
DefaultSolrReindexProvider

public interface SolrIndexProvider extends com.broadleafcommerce.search.provider.ReindexProvider<org.apache.solr.common.SolrInputDocument>
Interface to define basic interactions with Solr for (re)indexing.
Author:
Kelly Tisdell (ktisdell)
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    delete(List<String> documentIds, int commitWithinMillis, String... indexNames)
    Perform a delete operation, deleting a list of document IDs from Solr.
    void
    hardCommit(String... indexNames)
    Initiates a Solr soft commit to each of the indices.
    void
    rollback(String collection)
    Mechanism to allow rollbacks.
    void
    softCommit(String... indexNames)
    Initiates a Solr soft commit to each of the indices.
    void
    write(String collectionName, org.apache.solr.client.solrj.request.UpdateRequest updateRequest)
    Generic method to execute an UpdateRequest for Solr.
    void
    write(List<org.apache.solr.common.SolrInputDocument> documents, int commitWithinMillis, String... indexNames)
    Overloads the method from the super interface, allowing the caller to specify how long until this should be committed to the index for searching.
    void
    write(org.apache.solr.common.SolrInputDocument document, int commitWithinMillis, String... indexNames)
    Overloads the method from the super interface, allowing the caller to specify how long until this should be committed to the index for searching.

    Methods inherited from interface com.broadleafcommerce.search.provider.ReindexProvider

    deleteByField, write, write
  • Method Details

    • write

      void write(List<org.apache.solr.common.SolrInputDocument> documents, int commitWithinMillis, String... indexNames) throws com.broadleafcommerce.search.api.SearchIndexException
      Overloads the method from the super interface, allowing the caller to specify how long until this should be committed to the index for searching.

      If the commitWithinMillis is less than or equal to zero then it is ignored.

      Typically, commitWithinMillis will be between 1000-60000 (between 1-60 seconds).

      Use a negative number for commitWithinMillis when doing a full reindex, and use the hardCommit method at the end of the process. Note that the smaller the commitWithinMillis parameter, the more it affects performance. The larger the number, the longer it will take to be searchable.

      Parameters:
      documents - the documents to write
      commitWithinMillis - time to commit within after write
      indexNames - the indices to write to
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - if an error occurs writing to the index
    • write

      void write(org.apache.solr.common.SolrInputDocument document, int commitWithinMillis, String... indexNames) throws com.broadleafcommerce.search.api.SearchIndexException
      Overloads the method from the super interface, allowing the caller to specify how long until this should be committed to the index for searching.

      If the commitWithinMillis is less than or equal to zero then it is ignored.

      Typically, commitWithinMillis will be between 1000-60000 (between 1-60 seconds).

      Use a negative number for commitWithinMillis when doing a full reindex, and use the hardCommit method at the end of the process. Note that the smaller the commitWithinMillis parameter, the more it affects performance. The larger the number, the longer it will take to be searchable.

      Parameters:
      document - the document to write
      commitWithinMillis - time to commit within after write
      indexNames - the indices to write to
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - if an error occurs writing to the index
    • softCommit

      void softCommit(String... indexNames) throws com.broadleafcommerce.search.api.SearchIndexException
      Initiates a Solr soft commit to each of the indices. Soft commits make documents searchable, but do not necessarily make them persistent. Check the Solr documentation for more information.

      Remember that, unlike databases, Solr's commits and rollbacks are global, meaning that any client or thread that issues a commit or rollback does so for all clients and threads. It is a global process.

      Parameters:
      indexNames - the indices to soft commit
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - if an error occurs performing the soft commit
    • hardCommit

      void hardCommit(String... indexNames) throws com.broadleafcommerce.search.api.SearchIndexException
      Initiates a Solr soft commit to each of the indices. Soft commits make documents searchable, but do not necessarily make them persistent. Check the Solr documentation for more information.

      Remember that, unlike databases, Solr's commits and rollbacks are global, meaning that any client or thread that issues a commit or rollback does so for all clients and threads. It is a global process.

      WARNING: Use this with caution. This should only be used rarely by a single control thread to commit batches. This can have negative performance impacts if used liberally. As a result this should only be used by a single thread after a full or bulk reindex. Check the Solr documentation for more information.

      Parameters:
      indexNames - the indices to hard commit
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - if an error occurs performing the hard commit
    • write

      void write(String collectionName, org.apache.solr.client.solrj.request.UpdateRequest updateRequest) throws com.broadleafcommerce.search.api.SearchIndexException
      Generic method to execute an UpdateRequest for Solr. An update request allows for soft commits and for batches of SolrInputDocuments to be processed.
      Parameters:
      collectionName - the collection to update
      updateRequest - the update to write to the collection
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - if an error occurs performing the update
    • delete

      void delete(@Nullable List<String> documentIds, int commitWithinMillis, @NonNull String... indexNames) throws com.broadleafcommerce.search.api.SearchIndexException
      Perform a delete operation, deleting a list of document IDs from Solr.
      Parameters:
      documentIds - A list of document IDs to be deleted.
      commitWithinMillis - time to commit within after write
      indexNames - The name of the collections to update.
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException - If an error occurs deleting documents.
    • rollback

      void rollback(String collection) throws com.broadleafcommerce.search.api.SearchIndexException
      Mechanism to allow rollbacks. Remember that, unlike databases, Solr's commits and rollbacks are global, meaning that any client or thread that issues a commit or rollback does so for all clients and threads. It is a global process.
      Parameters:
      collection - the collection that should be rolled back
      Throws:
      com.broadleafcommerce.search.api.SearchIndexException