public class SolrSearchServiceImpl extends java.lang.Object implements SearchService, org.springframework.beans.factory.DisposableBean
| Modifier and Type | Field and Description |
|---|---|
protected SolrSearchServiceExtensionManager |
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(java.lang.String solrServer) |
| Modifier and Type | Method and Description |
|---|---|
void |
appendFieldToQuery(java.lang.StringBuilder queryBuilder,
Field currentField,
java.lang.String query) |
protected void |
attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
java.util.Map<java.lang.String,SearchFacetDTO> namedFacetMap,
ProductSearchCriteria searchCriteria)
Restricts the query by adding active facet filters.
|
protected void |
attachFacets(org.apache.solr.client.solrj.SolrQuery query,
java.util.Map<java.lang.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,
java.lang.String defaultSort)
Sets up the sorting criteria.
|
java.lang.String |
buildQueryString(java.lang.String query) |
protected java.util.List<SearchFacetDTO> |
buildSearchFacetDTOs(java.util.List<SearchFacet> searchFacets)
Create the wrapper DTO around the SearchFacet
|
java.io.File |
copyConfigToSolrHome(java.io.InputStream configIs,
java.lang.String parentDir,
java.lang.String configFileSimpleName) |
void |
destroy() |
protected boolean |
facetIsAvailable(SearchFacet facet,
java.util.Map<java.lang.String,java.lang.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(java.lang.String qualifiedSolrQuery,
java.util.List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria,
java.lang.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,
java.lang.String query,
ProductSearchCriteria searchCriteria)
Performs a search for products in the given category for the given query, taking into consideration
the ProductSearchCriteria
|
ProductSearchResult |
findProductsByQuery(java.lang.String query,
ProductSearchCriteria searchCriteria)
Performs a search for products across all categories for the given query, taking into consideration
the ProductSearchCriteria
|
java.util.List<SearchFacetDTO> |
getCategoryFacets(Category category)
Gets all available facets for a given category
|
java.lang.String |
getLocalePrefix() |
protected java.util.Map<java.lang.String,SearchFacetDTO> |
getNamedFacetMap(java.util.List<SearchFacetDTO> facets,
ProductSearchCriteria searchCriteria) |
protected java.util.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.
|
java.util.List<SearchFacetDTO> |
getSearchFacets()
Gets all available facets for search results page
|
protected java.lang.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 java.util.Map<java.lang.String,java.lang.String> |
getSolrFieldKeyMap(ProductSearchCriteria searchCriteria) |
protected java.lang.String |
getSolrFieldString(java.lang.String indexField,
SearchFacetRange range)
Returns a field string.
|
protected java.lang.String |
getSolrFieldTag(java.lang.String tagField,
java.lang.String tag)
Returns a solr field tag.
|
protected java.lang.String |
getSolrTaggedFieldString(java.lang.String indexField,
java.lang.String tagField,
java.lang.String tag,
SearchFacetRange range)
Returns a fully composed solr field string.
|
void |
rebuildIndex()
This method delegates to
SolrIndexService.rebuildIndex(). |
protected java.lang.String |
sanitizeQuery(java.lang.String query)
Perform any necessary query sanitation here.
|
protected void |
setFacetResults(java.util.Map<java.lang.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(java.util.Map<java.lang.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 SolrSearchServiceExtensionManager extensionManager
public SolrSearchServiceImpl(java.lang.String solrServer)
throws java.io.IOException,
javax.xml.parsers.ParserConfigurationException,
org.xml.sax.SAXException
java.io.IOExceptionjavax.xml.parsers.ParserConfigurationExceptionorg.xml.sax.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)
public java.io.File copyConfigToSolrHome(java.io.InputStream configIs,
java.lang.String parentDir,
java.lang.String configFileSimpleName)
throws java.io.IOException
java.io.IOExceptionpublic void rebuildIndex()
throws ServiceException,
java.io.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 SearchServiceServiceExceptionjava.io.IOExceptionpublic void destroy()
throws java.lang.Exception
destroy in interface org.springframework.beans.factory.DisposableBeanjava.lang.Exceptionpublic 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(java.lang.String query, ProductSearchCriteria searchCriteria) throws ServiceException
SearchServicefindProductsByQuery in interface SearchServiceServiceExceptionpublic java.lang.String buildQueryString(java.lang.String query)
public void appendFieldToQuery(java.lang.StringBuilder queryBuilder,
Field currentField,
java.lang.String query)
public ProductSearchResult findProductsByCategoryAndQuery(Category category, java.lang.String query, ProductSearchCriteria searchCriteria) throws ServiceException
SearchServicefindProductsByCategoryAndQuery in interface SearchServiceServiceExceptionpublic java.lang.String getLocalePrefix()
protected ProductSearchResult findProducts(java.lang.String qualifiedSolrQuery, java.util.List<SearchFacetDTO> facets, ProductSearchCriteria searchCriteria, java.lang.String defaultSort) throws ServiceException
qualifiedSolrQuery - facets - searchCriteria - ServiceExceptionpublic java.util.List<SearchFacetDTO> getSearchFacets()
SearchServicegetSearchFacets in interface SearchServicepublic java.util.List<SearchFacetDTO> getCategoryFacets(Category category)
SearchServicegetCategoryFacets in interface SearchServiceprotected void attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
ProductSearchCriteria searchCriteria,
java.lang.String defaultSort)
query - searchCriteria - protected void attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
java.util.Map<java.lang.String,SearchFacetDTO> namedFacetMap,
ProductSearchCriteria searchCriteria)
query - namedFacetMap - searchCriteria - protected void attachFacets(org.apache.solr.client.solrj.SolrQuery query,
java.util.Map<java.lang.String,SearchFacetDTO> namedFacetMap)
query - namedFacetMap - protected void setFacetResults(java.util.Map<java.lang.String,SearchFacetDTO> namedFacetMap, org.apache.solr.client.solrj.response.QueryResponse response)
namedFacetMap - response - protected void sortFacetResults(java.util.Map<java.lang.String,SearchFacetDTO> namedFacetMap)
namedFacetMap - public void setPagingAttributes(ProductSearchResult result, org.apache.solr.client.solrj.response.QueryResponse response, ProductSearchCriteria searchCriteria)
result - response - searchCriteria - protected java.util.List<Product> getProducts(org.apache.solr.client.solrj.response.QueryResponse response)
response - protected java.util.List<SearchFacetDTO> buildSearchFacetDTOs(java.util.List<SearchFacet> searchFacets)
searchFacets - protected boolean facetIsAvailable(SearchFacet facet, java.util.Map<java.lang.String,java.lang.String[]> params)
facet - request - protected java.lang.String sanitizeQuery(java.lang.String query)
query - protected java.lang.String getSolrFieldString(java.lang.String indexField,
SearchFacetRange range)
protected java.lang.String getSolrTaggedFieldString(java.lang.String indexField,
java.lang.String tagField,
java.lang.String tag,
SearchFacetRange range)
protected java.lang.String getSolrFieldTag(java.lang.String tagField,
java.lang.String tag)
protected java.util.Map<java.lang.String,SearchFacetDTO> getNamedFacetMap(java.util.List<SearchFacetDTO> facets, ProductSearchCriteria searchCriteria)
facets - searchCriteria - protected java.lang.String getSolrFieldKey(Field field, ProductSearchCriteria searchCriteria)
fields - searchCriteria - the searchCriteria in case it is needed to determine the field keyprotected java.util.Map<java.lang.String,java.lang.String> getSolrFieldKeyMap(ProductSearchCriteria searchCriteria)
searchCriteria - Copyright © 2018. All Rights Reserved.