@Service(value="blSolrIndexService") public class SolrIndexServiceImpl extends Object implements SolrIndexService
| Modifier and Type | Field and Description |
|---|---|
protected CategoryDao |
categoryDao |
protected boolean |
commit |
protected boolean |
errorOnConcurrentReIndex |
protected SolrSearchServiceExtensionManager |
extensionManager |
protected FieldDao |
fieldDao |
protected boolean |
IS_LOCKED |
protected LocaleService |
localeService |
protected Object |
LOCK_OBJECT |
protected int |
pageSize |
protected ProductDao |
productDao |
protected SandBoxHelper |
sandBoxHelper |
protected SolrHelperService |
shs |
protected SkuDao |
skuDao |
protected boolean |
softCommit |
protected SolrIndexDao |
solrIndexDao |
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager |
protected boolean |
useSku |
protected boolean |
waitFlush |
protected boolean |
waitSearcher |
| Constructor and Description |
|---|
SolrIndexServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
attachAdditionalDocumentFields(Product product,
org.apache.solr.common.SolrInputDocument document)
Implementors can extend this and override this method to add additional fields to the Solr document.
|
protected void |
attachAdditionalDocumentFields(Sku sku,
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(Product product,
org.apache.solr.common.SolrInputDocument document) |
protected void |
attachBasicDocumentFields(Sku sku,
org.apache.solr.common.SolrInputDocument document)
Adds the ID, category, and explicitCategory fields for the product or sku to the document
|
protected void |
buildCategoryDocument(Long categoryId,
Product product,
org.apache.solr.common.SolrInputDocument document,
CatalogStructure cache) |
org.apache.solr.common.SolrInputDocument |
buildDocument(Product product,
List<Field> 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.
|
org.apache.solr.common.SolrInputDocument |
buildDocument(Sku sku,
List<Field> fields,
List<Locale> locales)
Given a sku, fields that relate to that sku, 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 void |
buildIncrementalIndex(int page,
int pageSize) |
void |
buildIncrementalIndex(int page,
int pageSize,
boolean useReindexServer)
The internal method for building indexes.
|
void |
buildIncrementalProductIndex(List<Product> products,
boolean useReindexServer)
This can be used in lieu of passing in page sizes, The reason is that one might want to apply filters or only
index certain products.
|
void |
buildIncrementalSkuIndex(List<Sku> skus,
boolean useReindexServer)
This can be used in lieu of passing in page sizes, The reason is that one might want to apply filters or only
index certain skus.
|
void |
commit(org.apache.solr.client.solrj.SolrServer server)
Allows a commit to be called.
|
void |
commit(org.apache.solr.client.solrj.SolrServer server,
boolean softCommit,
boolean waitSearcher,
boolean waitFlush)
This allows an external caller to force a commit to the SolrServer.
|
protected Long |
convertDisplayOrderToLong(BigDecimal displayOrder)
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 void |
deleteAllDocuments()
Deprecated.
use
deleteAllReindexCoreDocuments() instead |
protected void |
deleteAllReindexCoreDocuments()
This method deletes all of the documents from
SolrContext.getReindexServer() |
protected Long |
determineDisplayOrderValue(CatalogStructure cache,
Long categoryId,
Product product)
Utility method to first try to read display order from cache
before making Database call.
|
List<Locale> |
getAllLocales() |
protected Map<String,Object> |
getPropertyValues(Object indexedItem,
Field field,
FieldType fieldType,
List<Locale> locales)
Returns a map of prefix to value for the requested attributes.
|
protected Tuple<CatalogStructure,Boolean> |
getStructuredCache(Product product) |
boolean |
isReindexInProcess()
Allows a query to determine if a full reindex is currently being performed.
|
void |
logDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
Prints out the docs to the trace logger
|
void |
optimizeIndex(org.apache.solr.client.solrj.SolrServer server)
Triggers the Solr optimize index function on the given server.
|
void |
performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation)
SolrIndexService exposes
SolrIndexService.buildIncrementalIndex(int, int, boolean). |
protected List<Product> |
readAllActiveProducts()
This method to read all active products will be slow if you have a large catalog.
|
protected List<Product> |
readAllActiveProducts(int page,
int pageSize)
This method to read active products utilizes paging to improve performance over
readAllActiveProducts(). |
protected List<Sku> |
readAllActiveSkus(int page,
int pageSize)
This method to read active skus utilizes paging to improve performance.
|
void |
rebuildIndex()
Rebuilds the current 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.
|
protected final Object LOCK_OBJECT
protected boolean IS_LOCKED
@Value(value="${solr.index.errorOnConcurrentReIndex}")
protected boolean errorOnConcurrentReIndex
@Value(value="${solr.index.product.pageSize}")
protected int pageSize
@Value(value="${solr.index.use.sku}")
protected boolean useSku
@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 SkuDao skuDao
protected CategoryDao categoryDao
protected FieldDao fieldDao
protected LocaleService localeService
protected SolrHelperService shs
protected SolrSearchServiceExtensionManager extensionManager
protected org.springframework.transaction.PlatformTransactionManager transactionManager
protected SolrIndexDao solrIndexDao
protected SandBoxHelper sandBoxHelper
public void performCachedOperation(SolrIndexCachedOperation.CacheOperation cacheOperation) throws ServiceException
SolrIndexServiceSolrIndexService.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 boolean isReindexInProcess()
SolrIndexServiceisReindexInProcess in interface SolrIndexServicepublic void rebuildIndex()
throws ServiceException,
IOException
SolrIndexServicerebuildIndex in interface SolrIndexServiceServiceExceptionIOException@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 documentsprotected void buildIncrementalIndex(int page,
int pageSize)
throws ServiceException
ServiceExceptionpublic void buildIncrementalProductIndex(List<Product> products, boolean useReindexServer) throws ServiceException
SolrIndexServicebuildIncrementalProductIndex in interface SolrIndexServiceServiceExceptionpublic void buildIncrementalSkuIndex(List<Sku> skus, boolean useReindexServer) throws ServiceException
SolrIndexServicebuildIncrementalSkuIndex in interface SolrIndexServiceServiceExceptionpublic void buildIncrementalIndex(int page,
int pageSize,
boolean useReindexServer)
throws ServiceException
SolrIndexServicebuildIncrementalIndex in interface SolrIndexServiceuseReindexServer - - if set to false will index directly on the primary serverServiceExceptionSolrIndexService.restoreState(Object[])protected List<Product> readAllActiveProducts()
protected List<Product> readAllActiveProducts(int page, int pageSize)
readAllActiveProducts().
While not optimal, this will reduce the memory required to load large catalogs.
It could still be improved for specific implementations by only loading fields that will be indexed or by accessing
the database via direct JDBC (instead of Hibernate).protected List<Sku> readAllActiveSkus(int page, int pageSize)
public List<Locale> getAllLocales()
getAllLocales in interface SolrIndexServicepublic org.apache.solr.common.SolrInputDocument buildDocument(Sku sku, List<Field> fields, List<Locale> locales)
SolrIndexServicebuildDocument in interface SolrIndexServicepublic org.apache.solr.common.SolrInputDocument buildDocument(Product product, List<Field> fields, List<Locale> locales)
SolrIndexServicebuildDocument in interface SolrIndexServiceprotected void attachAdditionalDocumentFields(Sku sku, org.apache.solr.common.SolrInputDocument document)
sku - document - protected void attachAdditionalDocumentFields(Product product, org.apache.solr.common.SolrInputDocument document)
product - document - protected void attachBasicDocumentFields(Sku sku, org.apache.solr.common.SolrInputDocument document)
sku - document - protected void attachBasicDocumentFields(Product product, org.apache.solr.common.SolrInputDocument document)
protected void buildCategoryDocument(Long categoryId, Product product, org.apache.solr.common.SolrInputDocument document, CatalogStructure cache)
categoryId - product - document - cache - protected Tuple<CatalogStructure,Boolean> getStructuredCache(Product product)
product - protected Long determineDisplayOrderValue(CatalogStructure cache, Long categoryId, Product product)
cache - categoryId - product - 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(Object indexedItem, Field field, FieldType fieldType, List<Locale> locales) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
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(org.apache.solr.client.solrj.SolrServer server)
throws ServiceException,
IOException
SolrIndexServiceoptimizeIndex in interface SolrIndexServiceServiceExceptionIOExceptionpublic void commit(org.apache.solr.client.solrj.SolrServer server)
throws ServiceException,
IOException
SolrIndexServicecommit in interface SolrIndexServiceServiceExceptionIOExceptionpublic void commit(org.apache.solr.client.solrj.SolrServer server,
boolean softCommit,
boolean waitSearcher,
boolean waitFlush)
throws ServiceException,
IOException
SolrIndexServicecommit in interface SolrIndexServiceserver - - the SolrServer 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.ServiceExceptionIOExceptionpublic void logDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
SolrIndexServicelogDocuments in interface SolrIndexServiceprotected Long convertDisplayOrderToLong(BigDecimal displayOrder)
Copyright © 2017. All rights reserved.