|
||||||||||
| 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. Note that prior to 2.2.0, this class used to contain all of the logic for interaction with Solr. Since 2.2.0, this class has been refactored and parts of it have been split into the other classes you can find in this package.
| Field Summary | |
|---|---|
protected SolrSearchServiceExtensionListener |
extensionManager
|
protected FieldDao |
fieldDao
|
protected ProductDao |
productDao
|
protected SearchFacetDao |
searchFacetDao
|
protected SolrHelperService |
shs
|
protected SolrIndexService |
solrIndexService
|
| Constructor Summary | |
|---|---|
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer)
|
|
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer)
|
|
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 |
File |
copyConfigToSolrHome(InputStream configIs,
String parentDir,
String configFileSimpleName)
|
void |
destroy()
|
protected boolean |
facetIsAvailable(SearchFacet facet,
Map<String,String[]> params)
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 |
List<SearchFacetDTO> |
getCategoryFacets(Category category)
Gets all available facets for a given category |
protected Map<String,SearchFacetDTO> |
getNamedFacetMap(List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria)
|
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. |
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()
This method delegates to SolrIndexService.rebuildIndex(). |
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 ProductDao productDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected SolrHelperService shs
protected SolrIndexService solrIndexService
protected SolrSearchServiceExtensionListener extensionManager
| Constructor Detail |
|---|
public SolrSearchServiceImpl(String solrServer)
throws IOException,
ParserConfigurationException,
SAXException
IOException
ParserConfigurationException
SAXExceptionpublic SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer)
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer)
| Method Detail |
|---|
public File copyConfigToSolrHome(InputStream configIs,
String parentDir,
String configFileSimpleName)
throws IOException
IOException
public void rebuildIndex()
throws ServiceException,
IOException
SearchServiceSolrIndexService.rebuildIndex(). It is here to preserve backwards-compatibility
with sites that were originally configured to run Broadleaf with Solr before 2.2.0.
rebuildIndex in interface SearchServiceServiceException
IOException
public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanException
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 SearchServiceServiceException
protected ProductSearchResult findProducts(String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria,
String defaultSort)
throws ServiceException
qualifiedSolrQuery - facets - searchCriteria -
ServiceExceptionpublic List<SearchFacetDTO> getSearchFacets()
SearchService
getSearchFacets in interface SearchServicepublic List<SearchFacetDTO> getCategoryFacets(Category category)
SearchService
getCategoryFacets in interface SearchService
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 List<SearchFacetDTO> buildSearchFacetDTOs(List<SearchFacet> searchFacets)
searchFacets -
protected boolean facetIsAvailable(SearchFacet facet,
Map<String,String[]> params)
facet - request -
protected String sanitizeQuery(String query)
query -
protected String getSolrFieldString(String indexField,
SearchFacetRange range)
protected String getSolrTaggedFieldString(String indexField,
String tagField,
String tag,
SearchFacetRange range)
protected String getSolrFieldTag(String tagField,
String tag)
protected Map<String,SearchFacetDTO> getNamedFacetMap(List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria)
facets - searchCriteria -
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 -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||