|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.broadleafcommerce.core.search.service.solr.SolrIndexServiceImpl
@Service(value="blSolrIndexService") public class SolrIndexServiceImpl
Responsible for building and rebuilding the Solr index
| Field Summary | |
|---|---|
static String |
ATTR_MAP
|
protected SolrSearchServiceExtensionManager |
extensionManager
|
protected FieldDao |
fieldDao
|
protected LocaleService |
localeService
|
protected int |
pageSize
|
protected ProductDao |
productDao
|
protected SolrHelperService |
shs
|
protected org.springframework.transaction.PlatformTransactionManager |
transactionManager
|
| Constructor Summary | |
|---|---|
SolrIndexServiceImpl()
|
|
| Method Summary | |
|---|---|
protected void |
attachBasicDocumentFields(Product product,
org.apache.solr.common.SolrInputDocument document)
Adds the ID, category, and explicitCategory fields for the product to the document |
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. |
protected void |
buildIncrementalIndex(int page,
int pageSize)
|
void |
buildIncrementalIndex(int page,
int pageSize,
boolean useReindexServer)
The internal method for building indexes. |
protected String |
convertToMappedProperty(String propertyName,
String listPropertyName,
String mapPropertyName)
Converts a propertyName to one that is able to reference inside a map. |
protected void |
deleteAllDocuments()
|
List<Locale> |
getAllLocales()
|
protected Map<String,Object> |
getPropertyValues(Product product,
Field field,
FieldType fieldType,
List<Locale> locales)
Returns a map of prefix to value for the requested attributes. |
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 |
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(). |
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. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
@Value(value="${solr.index.product.pageSize}")
protected int pageSize
protected ProductDao productDao
protected FieldDao fieldDao
protected LocaleService localeService
protected SolrHelperService shs
protected SolrSearchServiceExtensionManager extensionManager
protected org.springframework.transaction.PlatformTransactionManager transactionManager
public static String ATTR_MAP
| Constructor Detail |
|---|
public SolrIndexServiceImpl()
| Method Detail |
|---|
public void rebuildIndex()
throws ServiceException,
IOException
SolrIndexService
rebuildIndex in interface SolrIndexServiceServiceException
IOException
protected void deleteAllDocuments()
throws ServiceException
ServiceException
protected void buildIncrementalIndex(int page,
int pageSize)
throws ServiceException
ServiceException
public void buildIncrementalIndex(int page,
int pageSize,
boolean useReindexServer)
throws ServiceException
SolrIndexService
buildIncrementalIndex in interface SolrIndexServiceuseReindexServer - - if set to false will index directly on the primary server
ServiceExceptionSolrIndexService.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).
public List<Locale> getAllLocales()
getAllLocales in interface SolrIndexService
public org.apache.solr.common.SolrInputDocument buildDocument(Product product,
List<Field> fields,
List<Locale> locales)
SolrIndexService
buildDocument in interface SolrIndexService
protected void attachBasicDocumentFields(Product product,
org.apache.solr.common.SolrInputDocument document)
product - document -
protected Map<String,Object> getPropertyValues(Product product,
Field field,
FieldType fieldType,
List<Locale> locales)
throws IllegalAccessException,
InvocationTargetException,
NoSuchMethodException
product - field - isPriceField - prefix -
IllegalAccessException
InvocationTargetException
NoSuchMethodException
protected String convertToMappedProperty(String propertyName,
String listPropertyName,
String mapPropertyName)
propertyName - listPropertyName - mapPropertyName -
public Object[] saveState()
SolrIndexService
saveState in interface SolrIndexServicepublic void restoreState(Object[] pack)
SolrIndexService
restoreState in interface SolrIndexServiceSolrIndexService.saveState()
public void optimizeIndex(org.apache.solr.client.solrj.SolrServer server)
throws ServiceException,
IOException
SolrIndexService
optimizeIndex in interface SolrIndexServiceServiceException
IOExceptionpublic void logDocuments(Collection<org.apache.solr.common.SolrInputDocument> documents)
SolrIndexService
logDocuments in interface SolrIndexService
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||