Class DefaultSolrReindexProvider

    • Constructor Detail

      • DefaultSolrReindexProvider

        public DefaultSolrReindexProvider​(org.apache.solr.client.solrj.SolrClient client,
                                          @Nullable
                                          String userName,
                                          @Nullable
                                          String password,
                                          org.apache.solr.client.solrj.SolrRequest.METHOD submitMethod,
                                          int maxRetries,
                                          long pauseTime)
    • Method Detail

      • write

        public void write​(org.apache.solr.common.SolrInputDocument document,
                          String... indexNames)
                   throws com.broadleafcommerce.search.api.SearchIndexException
        Specified by:
        write in interface com.broadleafcommerce.search.provider.ReindexProvider<org.apache.solr.common.SolrInputDocument>
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException
      • write

        public void write​(List<org.apache.solr.common.SolrInputDocument> documents,
                          String... indexNames)
                   throws com.broadleafcommerce.search.api.SearchIndexException
        Specified by:
        write in interface com.broadleafcommerce.search.provider.ReindexProvider<org.apache.solr.common.SolrInputDocument>
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException
      • write

        public void write​(List<org.apache.solr.common.SolrInputDocument> documents,
                          int commitWithinMillis,
                          String... indexNames)
                   throws com.broadleafcommerce.search.api.SearchIndexException
        Description copied from interface: SolrIndexProvider
        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.

        Specified by:
        write in interface SolrIndexProvider
        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

        public void write​(org.apache.solr.common.SolrInputDocument document,
                          int commitWithinMillis,
                          String... indexNames)
                   throws com.broadleafcommerce.search.api.SearchIndexException
        Description copied from interface: SolrIndexProvider
        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.

        Specified by:
        write in interface SolrIndexProvider
        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

        public void softCommit​(String... indexNames)
                        throws com.broadleafcommerce.search.api.SearchIndexException
        Description copied from interface: SolrIndexProvider
        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.

        Specified by:
        softCommit in interface SolrIndexProvider
        Parameters:
        indexNames - the indices to soft commit
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException - if an error occurs performing the soft commit
      • hardCommit

        public void hardCommit​(String... indexNames)
                        throws com.broadleafcommerce.search.api.SearchIndexException
        Description copied from interface: SolrIndexProvider
        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.

        Specified by:
        hardCommit in interface SolrIndexProvider
        Parameters:
        indexNames - the indices to hard commit
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException - if an error occurs performing the hard commit
      • write

        public void write​(@NonNull
                          @NonNull String collectionName,
                          org.apache.solr.client.solrj.request.UpdateRequest updateRequest)
                   throws com.broadleafcommerce.search.api.SearchIndexException
        Description copied from interface: SolrIndexProvider
        Generic method to execute an UpdateRequest for Solr. An update request allows for soft commits and for batches of SolrInputDocuments to be processed.
        Specified by:
        write in interface SolrIndexProvider
        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

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

        public void rollback​(String collection)
                      throws com.broadleafcommerce.search.api.SearchIndexException
        Description copied from interface: SolrIndexProvider
        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.
        Specified by:
        rollback in interface SolrIndexProvider
        Parameters:
        collection - the collection that should be rolled back
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException
      • deleteByField

        public void deleteByField​(String fieldName,
                                  String fieldValue,
                                  int commitWithin,
                                  String... indexes)
                           throws com.broadleafcommerce.search.api.SearchIndexException
        Specified by:
        deleteByField in interface com.broadleafcommerce.search.provider.ReindexProvider<org.apache.solr.common.SolrInputDocument>
        Throws:
        com.broadleafcommerce.search.api.SearchIndexException
      • getMaxRetries

        protected int getMaxRetries()
      • getPauseTime

        protected long getPauseTime()
      • getSubmitMethod

        protected org.apache.solr.client.solrj.SolrRequest.METHOD getSubmitMethod()