public interface SolrIndexService
SolrIndexCachedOperation| Modifier and Type | Method and Description |
|---|---|
void |
addDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents) |
void |
attachIndexableDocumentFields(org.apache.solr.common.SolrInputDocument document,
Indexable indexable,
List<IndexField> fields,
List<Locale> locales)
Iterates through the fields for this indexable and indexes any SearchField's or SearchFacet's.
|
org.apache.solr.common.SolrInputDocument |
buildDocument(Indexable indexable,
List<IndexField> fields,
List<Locale> locales)
Given a product, fields that relate to that product, and a list of locales and pricelists, builds a
SolrInputDocument to be added to the Solr index.
|
Collection<org.apache.solr.common.SolrInputDocument> |
buildIncrementalIndex(List<? extends Indexable> indexables,
org.apache.solr.client.solrj.SolrClient solrServer)
Builds a set of
Indexables against the given SolrServer |
void |
buildIndex()
Handles all the document building for the current index rebuild.
|
void |
commit(org.apache.solr.client.solrj.SolrClient server)
Allows a commit to be called.
|
void |
commit(org.apache.solr.client.solrj.SolrClient server,
boolean softCommit,
boolean waitSearcher,
boolean waitFlush)
This allows an external caller to force a commit to the SolrClient.
|
void |
deleteAllDocuments(org.apache.solr.client.solrj.SolrClient server) |
void |
deleteAllNamespaceDocuments(org.apache.solr.client.solrj.SolrClient server) |
void |
deleteByQuery(String deleteQuery) |
void |
executeSolrIndexOperation(SolrIndexOperation operation)
Executes the given operation in the correct method order
|
List<Sku> |
filterIndexableSkus(List<Sku> skus)
Filters out Skus that shouldn't be indexed if any of the following are true:
|
List<Locale> |
getAllLocales() |
SolrIndexOperation |
getReindexOperation()
Creates the SolrIndexOperation for rebuilding the current index, used by
buildIndex(). |
void |
logDeleteQuery(String deleteQuery) |
void |
logDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
Prints out the docs to the trace logger
|
void |
optimizeIndex(org.apache.solr.client.solrj.SolrClient server)
Triggers the Solr optimize index function on the given server.
|
void |
performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation)
SolrIndexService exposes
#buildIncrementalIndex(int, int, boolean). |
void |
postBuildIndex()
Executed after we do any indexing when rebuilding the current index.
|
void |
preBuildIndex()
Executed before we do any indexing when rebuilding the index.
|
void |
rebuildIndex()
Executes a full rebuild of the Solr index.
|
void |
restoreState(Object[] pack)
Restores state that was saved prior to indexing that might have been altered.
|
Object[] |
saveState()
Saves some global context that might be altered during indexing.
|
void rebuildIndex()
throws ServiceException,
IOException
Executes a full rebuild of the Solr index. This will rebuild the index on a separate core/collection and then swap out the active core/collection with the new version of the index (essentially replacing all documents that are currently in the index).
The order of methods that are apart of rebuilding the entire index:
IOExceptionServiceExceptionvoid preBuildIndex()
throws ServiceException
rebuildIndex()ServiceExceptionvoid buildIndex()
throws IOException,
ServiceException
Handles all the document building for the current index rebuild. This is where all of the SolrIndexOperation's need to be created, executed and the documents built and added to the Solr index
This is the method that should be overridden to specify which operations should be run to build the correct index.
IOExceptionServiceException#rebuildIndex()},
#preBuildIndex()}void postBuildIndex()
throws IOException,
ServiceException
IOExceptionServiceExceptionSolrIndexOperation getReindexOperation()
buildIndex(). This is the primary
index operation used to rebuild the index.void executeSolrIndexOperation(SolrIndexOperation operation) throws ServiceException, IOException
operation - the SolrIndexOperation that is to be executedServiceExceptionIOExceptionCollection<org.apache.solr.common.SolrInputDocument> buildIncrementalIndex(List<? extends Indexable> indexables, org.apache.solr.client.solrj.SolrClient solrServer) throws ServiceException
Indexables against the given SolrServerindexables - the list of items to indexsolrServer - if non-null, adds and commits the indexed documents to the server. If this is null, this will
simply return the documents that were built from indexablesSolrInputDocuments that were built from the given indexablesServiceExceptionObject[] saveState()
void restoreState(Object[] pack)
pack - saveState()void optimizeIndex(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException,
IOException
rebuildIndex()server - ServiceExceptionIOExceptionvoid commit(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException,
IOException
server - ServiceExceptionIOExceptionvoid commit(org.apache.solr.client.solrj.SolrClient server,
boolean softCommit,
boolean waitSearcher,
boolean waitFlush)
throws ServiceException,
IOException
server - - the SolrClient to updatesoftCommit - - soft commit is an efficient commit that does not write the data to the file systemwaitSearcher - - whether or not to wait for a new searcher to be createdwaitFlush - - whether or not to wait for a flush to disk.ServiceExceptionIOExceptionvoid deleteAllNamespaceDocuments(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException
ServiceExceptionvoid deleteAllDocuments(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException
ServiceExceptionvoid logDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
documents - List<Locale> getAllLocales()
org.apache.solr.common.SolrInputDocument buildDocument(Indexable indexable, List<IndexField> fields, List<Locale> locales)
product - fields - locales - void performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation) throws ServiceException
#buildIncrementalIndex(int, int, boolean).
By wrapping the call to this method inside of a SolrIndexCachedOperation.CacheOperation,
a single cache will be used for all the contained calls to buildIncrementalIndex. Here's an example:
{@code
performCachedOperation(new SolrIndexCachedOperation.CacheOperation() {cacheOperation - the block of code to perform using a single cache for best performanceServiceExceptionList<Sku> filterIndexableSkus(List<Sku> skus)
Filters out Skus that shouldn't be indexed if any of the following are true:
skus - void attachIndexableDocumentFields(org.apache.solr.common.SolrInputDocument document,
Indexable indexable,
List<IndexField> fields,
List<Locale> locales)
document - indexable - fields - locales - void deleteByQuery(String deleteQuery) throws org.apache.solr.client.solrj.SolrServerException, IOException
org.apache.solr.client.solrj.SolrServerExceptionIOExceptionvoid addDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents) throws IOException, org.apache.solr.client.solrj.SolrServerException
IOExceptionorg.apache.solr.client.solrj.SolrServerExceptionvoid logDeleteQuery(String deleteQuery)
Copyright © 2025. All rights reserved.