|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.broadleafcommerce.core.search.service.solr.SolrSearchServiceImpl
public class SolrSearchServiceImpl
An implementation of SearchService that uses Solr
| Field Summary | |
|---|---|
protected static String |
DEFAULT_NAMESPACE
|
protected static Locale |
defaultLocale
|
protected SolrSearchServiceExtensionListener |
extensionManager
|
protected FieldDao |
fieldDao
|
protected static String |
GLOBAL_FACET_TAG_FIELD
|
protected LocaleService |
localeService
|
protected ProductDao |
productDao
|
protected SearchFacetDao |
searchFacetDao
|
protected org.apache.solr.client.solrj.SolrServer |
server
|
| Constructor Summary | |
|---|---|
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer)
|
|
SolrSearchServiceImpl(String solrServer)
|
|
| Method Summary | |
|---|---|
protected void |
attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
ProductSearchCriteria searchCriteria)
Restricts the query by adding active facet filters. |
protected void |
attachBasicDocumentFields(Product product,
org.apache.solr.common.SolrInputDocument document)
Adds the ID, category, and explicitCategory fields for the product to the document |
protected void |
attachFacets(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap)
Notifies solr about which facets you want it to determine results and counts for |
protected void |
attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
ProductSearchCriteria searchCriteria,
String defaultSort)
Sets up the sorting criteria. |
protected 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 List<SearchFacetDTO> |
buildSearchFacetDTOs(List<SearchFacet> searchFacets)
Create the wrapper DTO around the SearchFacet |
protected String |
convertToMappedProperty(String propertyName,
String listPropertyName,
String mapPropertyName)
Converts a propertyName to one that is able to reference inside a map. |
void |
destroy()
|
protected boolean |
facetIsAvailable(SearchFacet facet,
javax.servlet.http.HttpServletRequest request)
Checks to see if the requiredFacets condition for a given facet is met. |
ProductSearchResult |
findExplicitProductsByCategory(Category category,
ProductSearchCriteria searchCriteria)
Performs a search for products in the given category, taking into consideration the ProductSearchCriteria This method will NOT return products that are in a sub-level of a given category. |
protected ProductSearchResult |
findProducts(String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria,
String defaultSort)
Given a qualified solr query string (such as "category:2002"), actually performs a solr search. |
ProductSearchResult |
findProductsByCategory(Category category,
ProductSearchCriteria searchCriteria)
Performs a search for products in the given category, taking into consideration the ProductSearchCriteria This method will return products that are in any sub-level of a given category. |
ProductSearchResult |
findProductsByCategoryAndQuery(Category category,
String query,
ProductSearchCriteria searchCriteria)
Performs a search for products in the given category for the given query, taking into consideration the ProductSearchCriteria |
ProductSearchResult |
findProductsByQuery(String query,
ProductSearchCriteria searchCriteria)
Performs a search for products across all categories for the given query, taking into consideration the ProductSearchCriteria |
protected List<Locale> |
getAllLocales()
|
List<SearchFacetDTO> |
getCategoryFacets(Category category)
Gets all available facets for a given category |
protected String |
getCategoryFieldName()
|
protected String |
getCategorySortFieldName(Category category)
|
protected String |
getCurrentNamespace()
Determines the current namespace we are operating on. |
protected Locale |
getDefaultLocale()
Returns the default locale. |
protected String |
getDefaultLocalePrefix()
|
protected String |
getExplicitCategoryFieldName()
|
protected String |
getIdFieldName()
|
protected String |
getLocalePrefix()
Determines if there is a locale prefix that needs to be applied to the given field for this particular request. |
protected Map<String,SearchFacetDTO> |
getNamedFacetMap(List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria)
|
protected String |
getNamespaceFieldName()
|
protected List<Product> |
getProducts(org.apache.solr.client.solrj.response.QueryResponse response)
Given a list of product IDs from solr, this method will look up the IDs via the productDao and build out actual Product instances. |
protected String |
getPropertyNameForFieldFacet(Field field)
Returns the property name for the given field and its configured facet field type. |
protected String |
getPropertyNameForFieldFacet(Field field,
String prefix)
Returns the property name for the given field, its configured facet field type, and the given prefix |
protected String |
getPropertyNameForFieldSearchable(Field field,
FieldType searchableFieldType)
Returns the property name for the given field and field type. |
protected String |
getPropertyNameForFieldSearchable(Field field,
FieldType searchableFieldType,
String prefix)
Returns the property name for the given field, field type, and prefix |
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. |
protected String |
getSearchableFieldName()
|
protected String |
getSearchableFieldName(String prefix)
|
List<SearchFacetDTO> |
getSearchFacets()
Gets all available facets for search results page |
protected String |
getSolrFieldKey(Field field,
ProductSearchCriteria searchCriteria)
This method will be used to map a field abbreviation to the appropriate solr index field to use. |
protected Map<String,String> |
getSolrFieldKeyMap(ProductSearchCriteria searchCriteria)
|
protected String |
getSolrFieldString(String indexField,
SearchFacetRange range)
Returns a field string. |
protected String |
getSolrFieldTag(String tagField,
String tag)
Returns a solr field tag. |
protected String |
getSolrTaggedFieldString(String indexField,
String tagField,
String tag,
SearchFacetRange range)
Returns a fully composed solr field string. |
protected List<Product> |
readAllActiveProducts()
This method to read all active products will be slow if you have a large catalog. |
void |
rebuildIndex()
Rebuilds the current index. |
protected String |
sanitizeQuery(String query)
Perform any necessary query sanitation here. |
protected void |
setFacetResults(Map<String,SearchFacetDTO> namedFacetMap,
org.apache.solr.client.solrj.response.QueryResponse response)
Builds out the DTOs for facet results from the search. |
void |
setPagingAttributes(ProductSearchResult result,
org.apache.solr.client.solrj.response.QueryResponse response,
ProductSearchCriteria searchCriteria)
Sets the total results, the current page, and the page size on the ProductSearchResult. |
protected void |
sortFacetResults(Map<String,SearchFacetDTO> namedFacetMap)
Invoked to sort the facet results. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String GLOBAL_FACET_TAG_FIELD
protected static final String DEFAULT_NAMESPACE
protected static Locale defaultLocale
protected ProductDao productDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected LocaleService localeService
protected SolrSearchServiceExtensionListener extensionManager
protected org.apache.solr.client.solrj.SolrServer server
| Constructor Detail |
|---|
public SolrSearchServiceImpl(String solrServer)
throws IOException,
ParserConfigurationException,
SAXException
IOException
ParserConfigurationException
SAXExceptionpublic SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer)
| Method Detail |
|---|
public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanException
@Transactional(value="blTransactionManager")
public void rebuildIndex()
throws ServiceException,
IOException
SearchService
rebuildIndex in interface SearchServiceServiceException
IOExceptionprotected List<Product> readAllActiveProducts()
protected List<Locale> getAllLocales()
protected org.apache.solr.common.SolrInputDocument buildDocument(Product product,
List<Field> fields,
List<Locale> locales)
product - fields - locales -
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
public ProductSearchResult findExplicitProductsByCategory(Category category,
ProductSearchCriteria searchCriteria)
throws ServiceException
SearchService
findExplicitProductsByCategory in interface SearchServiceServiceExceptionSearchService.findProductsByCategory(Category, ProductSearchCriteria)
public ProductSearchResult findProductsByCategory(Category category,
ProductSearchCriteria searchCriteria)
throws ServiceException
SearchService
findProductsByCategory in interface SearchServiceServiceExceptionSearchService.findExplicitProductsByCategory(Category, ProductSearchCriteria)
public ProductSearchResult findProductsByQuery(String query,
ProductSearchCriteria searchCriteria)
throws ServiceException
SearchService
findProductsByQuery in interface SearchServiceServiceException
public ProductSearchResult findProductsByCategoryAndQuery(Category category,
String query,
ProductSearchCriteria searchCriteria)
throws ServiceException
SearchService
findProductsByCategoryAndQuery in interface SearchServiceServiceExceptionpublic List<SearchFacetDTO> getSearchFacets()
SearchService
getSearchFacets in interface SearchServicepublic List<SearchFacetDTO> getCategoryFacets(Category category)
SearchService
getCategoryFacets in interface SearchService
protected ProductSearchResult findProducts(String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria,
String defaultSort)
throws ServiceException
qualifiedSolrQuery - facets - searchCriteria -
ServiceException
protected void attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
ProductSearchCriteria searchCriteria,
String defaultSort)
query - searchCriteria -
protected void attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
ProductSearchCriteria searchCriteria)
query - namedFacetMap - searchCriteria -
protected void attachFacets(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap)
query - namedFacetMap -
protected void setFacetResults(Map<String,SearchFacetDTO> namedFacetMap,
org.apache.solr.client.solrj.response.QueryResponse response)
namedFacetMap - response - protected void sortFacetResults(Map<String,SearchFacetDTO> namedFacetMap)
namedFacetMap -
public void setPagingAttributes(ProductSearchResult result,
org.apache.solr.client.solrj.response.QueryResponse response,
ProductSearchCriteria searchCriteria)
result - response - searchCriteria - protected List<Product> getProducts(org.apache.solr.client.solrj.response.QueryResponse response)
response -
protected String getSolrTaggedFieldString(String indexField,
String tagField,
String tag,
SearchFacetRange range)
protected String getSolrFieldTag(String tagField,
String tag)
protected String getSolrFieldString(String indexField,
SearchFacetRange range)
protected List<SearchFacetDTO> buildSearchFacetDTOs(List<SearchFacet> searchFacets)
searchFacets -
protected boolean facetIsAvailable(SearchFacet facet,
javax.servlet.http.HttpServletRequest request)
facet - request -
protected String convertToMappedProperty(String propertyName,
String listPropertyName,
String mapPropertyName)
propertyName - listPropertyName - mapPropertyName -
protected String getSolrFieldKey(Field field,
ProductSearchCriteria searchCriteria)
fields - searchCriteria - the searchCriteria in case it is needed to determine the field key
protected Map<String,String> getSolrFieldKeyMap(ProductSearchCriteria searchCriteria)
searchCriteria -
protected Map<String,SearchFacetDTO> getNamedFacetMap(List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria)
facets - searchCriteria -
protected String sanitizeQuery(String query)
query -
protected String getCurrentNamespace()
protected String getLocalePrefix()
protected Locale getDefaultLocale()
protected String getDefaultLocalePrefix()
protected String getPropertyNameForFieldSearchable(Field field,
FieldType searchableFieldType,
String prefix)
field - searchableFieldType - prefix -
protected String getPropertyNameForFieldFacet(Field field,
String prefix)
field - prefix -
protected String getPropertyNameForFieldSearchable(Field field,
FieldType searchableFieldType)
field - searchableFieldType -
protected String getPropertyNameForFieldFacet(Field field)
field -
protected String getNamespaceFieldName()
protected String getIdFieldName()
protected String getCategoryFieldName()
protected String getExplicitCategoryFieldName()
protected String getSearchableFieldName(String prefix)
prefix -
protected String getSearchableFieldName()
protected String getCategorySortFieldName(Category category)
category -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||