public class SolrSearchServiceImpl extends Object implements SearchService, org.springframework.beans.factory.DisposableBean
| Modifier and Type | Field and Description |
|---|---|
protected SolrSearchServiceExtensionListener |
extensionManager |
protected FieldDao |
fieldDao |
protected ProductDao |
productDao |
protected SearchFacetDao |
searchFacetDao |
protected SolrHelperService |
shs |
protected SolrIndexService |
solrIndexService |
| Constructor and Description |
|---|
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) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
protected ProductDao productDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected SolrHelperService shs
protected SolrIndexService solrIndexService
protected SolrSearchServiceExtensionListener extensionManager
public SolrSearchServiceImpl(String solrServer) throws IOException, ParserConfigurationException, SAXException
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer)
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer)
public File copyConfigToSolrHome(InputStream configIs, String parentDir, String configFileSimpleName) throws IOException
IOExceptionpublic 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 SearchServiceServiceExceptionIOExceptionpublic void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionpublic ProductSearchResult findExplicitProductsByCategory(Category category, ProductSearchCriteria searchCriteria) throws ServiceException
SearchServicefindExplicitProductsByCategory in interface SearchServiceServiceExceptionSearchService.findProductsByCategory(Category, ProductSearchCriteria)public ProductSearchResult findProductsByCategory(Category category, ProductSearchCriteria searchCriteria) throws ServiceException
SearchServicefindProductsByCategory in interface SearchServiceServiceExceptionSearchService.findExplicitProductsByCategory(Category, ProductSearchCriteria)public ProductSearchResult findProductsByQuery(String query, ProductSearchCriteria searchCriteria) throws ServiceException
SearchServicefindProductsByQuery in interface SearchServiceServiceExceptionpublic ProductSearchResult findProductsByCategoryAndQuery(Category category, String query, ProductSearchCriteria searchCriteria) throws ServiceException
SearchServicefindProductsByCategoryAndQuery in interface SearchServiceServiceExceptionprotected ProductSearchResult findProducts(String qualifiedSolrQuery, List<SearchFacetDTO> facets, ProductSearchCriteria searchCriteria, String defaultSort) throws ServiceException
qualifiedSolrQuery - facets - searchCriteria - ServiceExceptionpublic List<SearchFacetDTO> getSearchFacets()
SearchServicegetSearchFacets in interface SearchServicepublic List<SearchFacetDTO> getCategoryFacets(Category category)
SearchServicegetCategoryFacets in interface SearchServiceprotected 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 keyprotected Map<String,String> getSolrFieldKeyMap(ProductSearchCriteria searchCriteria)
searchCriteria - Copyright © 2014. All Rights Reserved.