|
||||||||||
| 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 FieldDao |
fieldDao
|
protected static String |
GLOBAL_FACET_TAG_FIELD
|
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 |
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 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()
|
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 |
List<SearchFacetDTO> |
getCategoryFacets(Category category)
Gets all available facets for a given category |
protected String |
getCategoryFieldName()
|
protected String |
getCategorySortField(Category category)
|
protected String |
getExplicitCategoryFieldName()
|
protected String |
getGlobalPrefix()
Determines if there is a prefix that needs to be applied to all fields for this particular request. |
protected String |
getIdFieldName()
|
protected String |
getLocalePrefix()
Determines if there is a locale prefix that needs to be applied to fields for this particular request. |
protected Map<String,SearchFacetDTO> |
getNamedFacetMap(List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria)
|
protected String |
getPricelistPrefix()
Determines if there is a pricelist prefix that needs to be applied to fields for this particular request. |
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 |
getPropertyNameForFieldSearchable(Field field,
FieldType searchableFieldType)
Returns the property name for the given field and field type. |
protected String |
getSearchableFieldName()
|
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. |
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 ProductDao productDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
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
IOException
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 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 getGlobalPrefix()
protected String getLocalePrefix()
protected String getPricelistPrefix()
protected String getPropertyNameForFieldSearchable(Field field,
FieldType searchableFieldType)
field - searchableFieldType -
protected String getPropertyNameForFieldFacet(Field field)
field -
protected String getIdFieldName()
protected String getSearchableFieldName()
protected String getCategoryFieldName()
protected String getExplicitCategoryFieldName()
protected String getCategorySortField(Category category)
category -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||