@Service(value="blSolrIndexService") public class SolrIndexServiceImpl extends Object implements SolrIndexService
| Modifier and Type | Field and Description |
|---|---|
protected CatalogService |
catalogService |
protected boolean |
commit |
protected boolean |
errorOnConcurrentReIndex |
protected SolrIndexServiceExtensionManager |
extensionManager |
protected FieldDao |
fieldDao |
protected IndexFieldDao |
indexFieldDao |
protected LocaleService |
localeService |
protected int |
pageSize |
protected ProductDao |
productDao |
protected SandBoxHelper |
sandBoxHelper |
protected SearchFacetDao |
searchFacetDao |
protected SolrHelperService |
shs |
protected boolean |
softCommit |
protected SolrConfiguration |
solrConfiguration |
protected SolrIndexDao |
solrIndexDao |
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager |
protected boolean |
waitFlush |
protected boolean |
waitSearcher |
| Constructor and Description |
|---|
SolrIndexServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents) |
protected void |
attachAdditionalDocumentFields(Indexable indexable,
org.apache.solr.common.SolrInputDocument document)
Implementors can extend this and override this method to add additional fields to the Solr document.
|
protected void |
attachBasicDocumentFields(Indexable indexable,
org.apache.solr.common.SolrInputDocument document) |
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.
|
protected void |
buildFullCategoryHierarchy(org.apache.solr.common.SolrInputDocument document,
CatalogStructure cache,
Long categoryId,
Set<Long> indexedParents)
Walk the category hierarchy upwards, adding a field for each level to the solr document
|
protected Long |
buildIncrementalIndex(int pageSize,
Long lastId,
SolrIndexOperation operation) |
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 |
Collection<org.apache.solr.common.SolrInputDocument> |
buildIncrementalIndex(String collection,
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.
|
protected String |
buildPageNumberMessage(int page,
Long totalPages) |
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 |
commit(String collection,
org.apache.solr.client.solrj.SolrClient server)
Allows a commit to be called.
|
void |
commit(String collection,
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.
|
protected Long |
convertDisplayOrderToLong(CatalogStructure cache,
String displayOrderKey)
We multiply the BigDecimal by 1,000,000 to maintain any possible decimals in use the
displayOrder value.
|
protected String |
convertToMappedProperty(String propertyName,
String listPropertyName,
String mapPropertyName)
Deprecated.
see SolrHelperService.getPropertyValue()
|
protected Long |
countIndexableItems() |
protected void |
deleteAllDocuments()
Deprecated.
use
deleteAllReindexCoreDocuments() instead |
void |
deleteAllDocuments(org.apache.solr.client.solrj.SolrClient server) |
void |
deleteAllDocuments(String collection,
org.apache.solr.client.solrj.SolrClient server) |
void |
deleteAllNamespaceDocuments(org.apache.solr.client.solrj.SolrClient server) |
void |
deleteAllNamespaceDocuments(String collection,
org.apache.solr.client.solrj.SolrClient server) |
protected void |
deleteAllReindexCoreDocuments()
This method deletes all of the documents from
SolrContext#getReindexServer() |
void |
deleteByQuery(String deleteQuery) |
void |
executeSolrIndexOperation(SolrIndexOperation operation)
Executes the given operation in the correct method order
|
List<Locale> |
getAllLocales() |
protected Map<String,Object> |
getPropertyValues(Indexable indexedItem,
Field field,
FieldType fieldType,
List<Locale> locales)
Returns a map of prefix to value for the requested attributes.
|
SolrIndexOperation |
getReindexOperation()
Creates the SolrIndexOperation for rebuilding the current index, used by
SolrIndexService.buildIndex(). |
protected long |
getTotalPageCount(Long numItemsToIndex) |
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 |
optimizeIndex(String collection,
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.
|
protected List<? extends Indexable> |
readAllActiveIndexables(int pageSize,
Long lastId) |
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.
|
@Qualifier(value="blCatalogSolrConfiguration") @Autowired(required=false) protected SolrConfiguration solrConfiguration
@Value(value="${solr.index.errorOnConcurrentReIndex}")
protected boolean errorOnConcurrentReIndex
@Value(value="${solr.index.product.pageSize}")
protected int pageSize
@Value(value="${solr.index.commit}")
protected boolean commit
@Value(value="${solr.index.softCommit}")
protected boolean softCommit
@Value(value="${solr.index.waitSearcher}")
protected boolean waitSearcher
@Value(value="${solr.index.waitFlush}")
protected boolean waitFlush
protected ProductDao productDao
protected CatalogService catalogService
protected FieldDao fieldDao
protected LocaleService localeService
protected SolrHelperService shs
protected SolrIndexServiceExtensionManager extensionManager
protected org.springframework.transaction.PlatformTransactionManager transactionManager
protected SolrIndexDao solrIndexDao
protected SandBoxHelper sandBoxHelper
protected SearchFacetDao searchFacetDao
protected IndexFieldDao indexFieldDao
public void performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation) throws ServiceException
SolrIndexService#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() {performCachedOperation in interface SolrIndexServicecacheOperation - the block of code to perform using a single cache for best performanceServiceExceptionpublic void rebuildIndex()
throws ServiceException,
IOException
SolrIndexServiceExecutes 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:
rebuildIndex in interface SolrIndexServiceServiceExceptionIOExceptionpublic void preBuildIndex()
throws ServiceException
SolrIndexServiceSolrIndexService.rebuildIndex()preBuildIndex in interface SolrIndexServiceServiceExceptionpublic void buildIndex()
throws IOException,
ServiceException
SolrIndexServiceHandles 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.
buildIndex in interface SolrIndexServiceIOExceptionServiceException#rebuildIndex()},
#preBuildIndex()}public void postBuildIndex()
throws IOException,
ServiceException
SolrIndexServicepostBuildIndex in interface SolrIndexServiceIOExceptionServiceExceptionpublic SolrIndexOperation getReindexOperation()
SolrIndexServiceSolrIndexService.buildIndex(). This is the primary
index operation used to rebuild the index.getReindexOperation in interface SolrIndexServicepublic void executeSolrIndexOperation(SolrIndexOperation operation) throws ServiceException, IOException
SolrIndexServiceexecuteSolrIndexOperation in interface SolrIndexServiceoperation - the SolrIndexOperation that is to be executedServiceExceptionIOExceptionprotected long getTotalPageCount(Long numItemsToIndex)
protected Long countIndexableItems()
@Deprecated protected void deleteAllDocuments() throws ServiceException
deleteAllReindexCoreDocuments() instead
This method deletes all of the documents from SolrContext#getReindexServer()
ServiceException - if there was a problem removing the documentsprotected void deleteAllReindexCoreDocuments()
throws ServiceException
This method deletes all of the documents from SolrContext#getReindexServer()
ServiceException - if there was a problem removing the documentspublic void deleteAllNamespaceDocuments(String collection, org.apache.solr.client.solrj.SolrClient server) throws ServiceException
deleteAllNamespaceDocuments in interface SolrIndexServiceServiceExceptionpublic void deleteAllDocuments(String collection, org.apache.solr.client.solrj.SolrClient server) throws ServiceException
deleteAllDocuments in interface SolrIndexServiceServiceExceptionprotected Long buildIncrementalIndex(int pageSize, Long lastId, SolrIndexOperation operation) throws ServiceException
ServiceExceptionpublic Collection<org.apache.solr.common.SolrInputDocument> buildIncrementalIndex(String collection, List<? extends Indexable> indexables, org.apache.solr.client.solrj.SolrClient solrServer) throws ServiceException
SolrIndexServiceIndexables against the given SolrServerbuildIncrementalIndex in interface SolrIndexServicecollection - The collection to be used for incremental indexingindexables - 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 indexablesServiceExceptionprotected List<? extends Indexable> readAllActiveIndexables(int pageSize, Long lastId)
public List<Locale> getAllLocales()
getAllLocales in interface SolrIndexServicepublic org.apache.solr.common.SolrInputDocument buildDocument(Indexable indexable, List<IndexField> fields, List<Locale> locales)
SolrIndexServicebuildDocument in interface SolrIndexServicepublic void attachIndexableDocumentFields(org.apache.solr.common.SolrInputDocument document,
Indexable indexable,
List<IndexField> fields,
List<Locale> locales)
SolrIndexServiceattachIndexableDocumentFields in interface SolrIndexServiceprotected void attachAdditionalDocumentFields(Indexable indexable, org.apache.solr.common.SolrInputDocument document)
sku - document - protected void attachBasicDocumentFields(Indexable indexable, org.apache.solr.common.SolrInputDocument document)
protected void buildFullCategoryHierarchy(org.apache.solr.common.SolrInputDocument document,
CatalogStructure cache,
Long categoryId,
Set<Long> indexedParents)
document - the solr document for the productcache - the catalog structure cachecategoryId - the current category idprotected Map<String,Object> getPropertyValues(Indexable indexedItem, Field field, FieldType fieldType, List<Locale> locales) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
product - sku - field - fieldType - locales - IllegalAccessExceptionInvocationTargetExceptionNoSuchMethodException@Deprecated protected String convertToMappedProperty(String propertyName, String listPropertyName, String mapPropertyName)
propertyName - listPropertyName - mapPropertyName - public Object[] saveState()
SolrIndexServicesaveState in interface SolrIndexServicepublic void restoreState(Object[] pack)
SolrIndexServicerestoreState in interface SolrIndexServiceSolrIndexService.saveState()public void optimizeIndex(String collection, org.apache.solr.client.solrj.SolrClient server) throws ServiceException, IOException
SolrIndexServiceSolrIndexService.rebuildIndex()optimizeIndex in interface SolrIndexServicecollection - The collection to optimizeserver - The server to use to optimze the given collectionServiceExceptionIOExceptionpublic void commit(String collection, org.apache.solr.client.solrj.SolrClient server) throws ServiceException, IOException
SolrIndexServicecommit in interface SolrIndexServicecollection - The collection to commitserver - The server used to commit the specified collectionServiceExceptionIOExceptionpublic void commit(String collection, org.apache.solr.client.solrj.SolrClient server, boolean softCommit, boolean waitSearcher, boolean waitFlush) throws ServiceException, IOException
SolrIndexServicecommit in interface SolrIndexServicecollection - The collection to commitserver - - the SolrClient to use to commit the provided collectionsoftCommit - - 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.ServiceExceptionIOExceptionpublic void logDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
SolrIndexServicelogDocuments in interface SolrIndexServiceprotected Long convertDisplayOrderToLong(CatalogStructure cache, String displayOrderKey)
cache - displayOrderKey - public void deleteByQuery(String deleteQuery) throws org.apache.solr.client.solrj.SolrServerException, IOException
deleteByQuery in interface SolrIndexServiceorg.apache.solr.client.solrj.SolrServerExceptionIOExceptionpublic void addDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents) throws IOException, org.apache.solr.client.solrj.SolrServerException
addDocuments in interface SolrIndexServiceIOExceptionorg.apache.solr.client.solrj.SolrServerExceptionpublic void logDeleteQuery(String deleteQuery)
logDeleteQuery in interface SolrIndexServicepublic Collection<org.apache.solr.common.SolrInputDocument> buildIncrementalIndex(List<? extends Indexable> indexables, org.apache.solr.client.solrj.SolrClient solrServer) throws ServiceException
SolrIndexServiceIndexables against the given SolrServerbuildIncrementalIndex in interface SolrIndexServiceindexables - 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 indexablesServiceExceptionpublic void optimizeIndex(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException,
IOException
SolrIndexServiceSolrIndexService.rebuildIndex()optimizeIndex in interface SolrIndexServiceserver - The server to use to optimze the default collectionServiceExceptionIOExceptionpublic void commit(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException,
IOException
SolrIndexServicecommit in interface SolrIndexServiceserver - The server used to commit the default collectionServiceExceptionIOExceptionpublic void commit(org.apache.solr.client.solrj.SolrClient server,
boolean softCommit,
boolean waitSearcher,
boolean waitFlush)
throws ServiceException,
IOException
SolrIndexServicecommit in interface SolrIndexServiceserver - - the SolrClient to commit withsoftCommit - - 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.ServiceExceptionIOExceptionpublic void deleteAllNamespaceDocuments(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException
deleteAllNamespaceDocuments in interface SolrIndexServiceServiceExceptionpublic void deleteAllDocuments(org.apache.solr.client.solrj.SolrClient server)
throws ServiceException
deleteAllDocuments in interface SolrIndexServiceServiceExceptionCopyright © 2019. All rights reserved.