Class DefaultSolrReindexProvider
- All Implemented Interfaces:
com.broadleafcommerce.search.provider.ReindexProvider<org.apache.solr.common.SolrInputDocument>
,SolrIndexProvider
,SolrProvider
SolrIndexProvider
that writes SolrInputDocuments to Solr.- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
Fields inherited from class com.broadleafcommerce.search.provider.solr.AbstractBasicAuthAwareSolrProvider
CLUSTER_STATUS_PATH
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSolrReindexProvider
(org.apache.solr.client.solrj.SolrClient client, String userName, String password, org.apache.solr.client.solrj.SolrRequest.METHOD submitMethod, int maxRetries, long pauseTime) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform a delete operation, deleting a list of document IDs from Solr.void
deleteByField
(String fieldName, String fieldValue, int commitWithin, String... indexes) protected int
protected long
protected org.apache.solr.client.solrj.SolrRequest.METHOD
void
hardCommit
(String... indexNames) Initiates a Solr soft commit to each of the indices.void
Mechanism to allow rollbacks.void
softCommit
(String... indexNames) Initiates a Solr soft commit to each of the indices.void
write
(@NonNull String collectionName, org.apache.solr.client.solrj.request.UpdateRequest updateRequest) Generic method to execute anUpdateRequest
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
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.void
Methods inherited from class com.broadleafcommerce.search.provider.solr.AbstractBasicAuthAwareSolrProvider
determineCollectionsFromAliases, getSolrBasicAuthPassword, getSolrBasicAuthUser, getSolrClient, reloadCollections, reloadCollectionsFromAliases, setBasicAuthCredentialsIfNecessary
-
Constructor Details
-
DefaultSolrReindexProvider
-
-
Method Details
-
write
public void write(org.apache.solr.common.SolrInputDocument document, String... indexNames) throws com.broadleafcommerce.search.api.SearchIndexException - Specified by:
write
in interfacecom.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 interfacecom.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 interfaceSolrIndexProvider
- Parameters:
documents
- the documents to writecommitWithinMillis
- time to commit within after writeindexNames
- 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 interfaceSolrIndexProvider
- Parameters:
document
- the document to writecommitWithinMillis
- time to commit within after writeindexNames
- 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 interfaceSolrIndexProvider
- 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 interfaceSolrIndexProvider
- 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 anUpdateRequest
for Solr. An update request allows for soft commits and for batches of SolrInputDocuments to be processed.- Specified by:
write
in interfaceSolrIndexProvider
- Parameters:
collectionName
- the collection to updateupdateRequest
- 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 interfaceSolrIndexProvider
- Parameters:
documentIds
- A list of document IDs to be deleted.commitWithinMillis
- time to commit within after writeindexes
- 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 interfaceSolrIndexProvider
- 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 interfacecom.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()
-