public class SolrSearchServiceImpl extends Object implements SearchService, org.springframework.beans.factory.DisposableBean
| Modifier and Type | Field and Description |
|---|---|
protected SolrSearchServiceExtensionManager |
extensionManager |
protected FieldDao |
fieldDao |
protected boolean |
globalFacetsForCategorySearch |
protected IndexFieldDao |
indexFieldDao |
protected ProductDao |
productDao |
protected SearchFacetDao |
searchFacetDao |
protected SolrHelperService |
shs |
protected SkuDao |
skuDao |
protected SolrConfiguration |
solrConfiguration |
protected SolrIndexService |
solrIndexService |
protected boolean |
useSku |
| Constructor and Description |
|---|
SolrSearchServiceImpl() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
SearchCriteria searchCriteria)
Restricts the query by adding active facet filters.
|
protected void |
attachFacets(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
SearchCriteria searchCriteria)
Notifies solr about which facets you want it to determine results and counts for
|
protected void |
attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
SearchCriteria searchCriteria,
String defaultSort)
Sets up the sorting criteria.
|
protected String |
buildQueryFieldsString(org.apache.solr.client.solrj.SolrQuery query,
SearchCriteria searchCriteria) |
protected List<SearchFacetDTO> |
buildSearchFacetDTOs(List<SearchFacet> searchFacets)
Create the wrapper DTO around the SearchFacet
|
void |
destroy() |
protected boolean |
facetIsAvailable(SearchFacet facet,
Map<String,String[]> params)
Checks to see if the requiredFacets condition for a given facet is met.
|
SearchResult |
findExplicitSearchResultsByCategory(Category category,
SearchCriteria searchCriteria)
Performs a search for search results in the given category, taking into consideration the SearchCriteria
This method will NOT return search results that are in a sub-level of a given category.
|
SearchResult |
findSearchResults(SearchCriteria searchCriteria)
Performs a search for search results based on the given SearchCriteria, if SearchCriteria has a category, the category
is considering for the search.
|
protected SearchResult |
findSearchResults(String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
SearchCriteria searchCriteria,
String defaultSort)
Deprecated.
in favor of the other findSearchResults() method
|
protected SearchResult |
findSearchResults(String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
SearchCriteria searchCriteria,
String defaultSort,
String... filterQueries)
Given a qualified solr query string (such as "category:2002"), actually performs a solr search.
|
SearchResult |
findSearchResultsByCategory(Category category,
SearchCriteria searchCriteria)
Deprecated.
|
SearchResult |
findSearchResultsByCategoryAndQuery(Category category,
String query,
SearchCriteria searchCriteria)
Deprecated.
|
SearchResult |
findSearchResultsByQuery(String query,
SearchCriteria searchCriteria)
Deprecated.
|
List<SearchFacetDTO> |
getCategoryFacets(Category category)
Gets all available facets for a given category
|
protected String |
getCategoryFilter(SearchCriteria searchCriteria) |
protected String |
getDefaultSort(SearchCriteria criteria) |
String |
getLocalePrefix() |
protected Map<String,SearchFacetDTO> |
getNamedFacetMap(List<SearchFacetDTO> facets,
SearchCriteria searchCriteria) |
protected List<Product> |
getProducts(List<org.apache.solr.common.SolrDocument> responseDocuments)
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 void |
getQueryFields(org.apache.solr.client.solrj.SolrQuery query,
List<String> queryFields,
IndexField indexField,
SearchCriteria searchCriteria)
This helper method gathers the query fields for the given field and stores them in the List parameter.
|
protected List<org.apache.solr.common.SolrDocument> |
getResponseDocuments(org.apache.solr.client.solrj.response.QueryResponse response) |
List<SearchFacetDTO> |
getSearchFacets()
Gets all available facets for search results page
|
List<SearchFacetDTO> |
getSearchFacets(Category category)
Gets all available facets for the given category and global search
|
protected List<Sku> |
getSkus(List<org.apache.solr.common.SolrDocument> responseDocuments)
Given a list of Sku IDs from solr, this method will look up the IDs via the skuDao and build out
actual Sku instances.
|
protected String |
getSolrFieldTag(String tagField,
String tag,
SearchFacetRange range)
Returns a solr field tag.
|
protected org.apache.solr.client.solrj.SolrRequest.METHOD |
getSolrQueryMethod()
Allows the user to choose the query method to use.
|
protected String |
getSolrRangeFunctionString(BigDecimal minValue,
BigDecimal maxValue) |
protected String |
getSolrRangeString(String fieldName,
BigDecimal minValue,
BigDecimal maxValue) |
protected String |
getSolrTaggedFieldString(String indexField,
String tag,
SearchFacetRange range)
Returns a fully composed solr field string.
|
protected void |
modifySolrQuery(org.apache.solr.client.solrj.SolrQuery query,
String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
SearchCriteria searchCriteria,
String defaultSort)
Provides a hook point for implementations to modify all SolrQueries before they're executed.
|
void |
rebuildIndex()
This method delegates to
SolrIndexService.rebuildIndex(). |
protected String |
sanitizeQuery(String query)
Perform any necessary query sanitation here.
|
protected String |
scrubFacetValue(String facetValue)
Scrubs a facet value string for all Solr special characters, automatically adding escape characters
|
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(SearchResult result,
int numResults,
SearchCriteria searchCriteria)
Sets the total results, the current page, and the page size on the ProductSearchResult.
|
protected boolean |
shouldShowDebugQuery() |
protected void |
sortFacetResults(Map<String,SearchFacetDTO> namedFacetMap)
Invoked to sort the facet results.
|
@Qualifier(value="blCatalogSolrConfiguration") @Autowired(required=false) protected SolrConfiguration solrConfiguration
@Value(value="${solr.index.use.sku}")
protected boolean useSku
protected ProductDao productDao
protected SkuDao skuDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected SolrHelperService shs
protected SolrIndexService solrIndexService
protected IndexFieldDao indexFieldDao
protected SolrSearchServiceExtensionManager extensionManager
@Value(value="${solr.global.facets.category.search:false}")
protected boolean globalFacetsForCategorySearch
protected boolean shouldShowDebugQuery()
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 SearchServiceServiceExceptionIOExceptionpublic SearchResult findExplicitSearchResultsByCategory(Category category, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindExplicitSearchResultsByCategory in interface SearchServiceServiceExceptionSearchService.findSearchResultsByCategory(Category, SearchCriteria)@Deprecated public SearchResult findSearchResultsByCategory(Category category, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResultsByCategory in interface SearchServiceServiceExceptionSearchService.findExplicitSearchResultsByCategory(Category, SearchCriteria)@Deprecated public SearchResult findSearchResultsByQuery(String query, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResultsByQuery in interface SearchServiceServiceException@Deprecated public SearchResult findSearchResultsByCategoryAndQuery(Category category, String query, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResultsByCategoryAndQuery in interface SearchServiceServiceExceptionpublic SearchResult findSearchResults(SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResults in interface SearchServicesearchCriteria - contains the information about this given searchServiceException@Deprecated protected SearchResult findSearchResults(String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) throws ServiceException
ServiceExceptionprotected SearchResult findSearchResults(String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort, String... filterQueries) throws ServiceException
searchCriteria - facets - ServiceExceptionprotected String getDefaultSort(SearchCriteria criteria)
protected String getCategoryFilter(SearchCriteria searchCriteria)
public String getLocalePrefix()
protected String buildQueryFieldsString(org.apache.solr.client.solrj.SolrQuery query, SearchCriteria searchCriteria)
protected void getQueryFields(org.apache.solr.client.solrj.SolrQuery query,
List<String> queryFields,
IndexField indexField,
SearchCriteria searchCriteria)
currentField - the current fieldquery - queryFields - the query fields for this querysearchCriteria - protected void modifySolrQuery(org.apache.solr.client.solrj.SolrQuery query,
String qualifiedSolrQuery,
List<SearchFacetDTO> facets,
SearchCriteria searchCriteria,
String defaultSort)
SolrSearchServiceExtensionHandler.modifySolrQuery(SolrQuery, String, List, SearchCriteria, String)query - qualifiedSolrQuery - facets - searchCriteria - defaultSort - protected List<org.apache.solr.common.SolrDocument> getResponseDocuments(org.apache.solr.client.solrj.response.QueryResponse response)
public List<SearchFacetDTO> getSearchFacets()
SearchServicegetSearchFacets in interface SearchServicepublic List<SearchFacetDTO> getSearchFacets(Category category)
SearchServicegetSearchFacets in interface SearchServicepublic List<SearchFacetDTO> getCategoryFacets(Category category)
SearchServicegetCategoryFacets in interface SearchServiceprotected void attachSortClause(org.apache.solr.client.solrj.SolrQuery query,
SearchCriteria searchCriteria,
String defaultSort)
query - searchCriteria - protected void attachActiveFacetFilters(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
SearchCriteria searchCriteria)
query - namedFacetMap - searchCriteria - protected String scrubFacetValue(String facetValue)
facetValue - The raw facet valueprotected void attachFacets(org.apache.solr.client.solrj.SolrQuery query,
Map<String,SearchFacetDTO> namedFacetMap,
SearchCriteria searchCriteria)
query - namedFacetMap - searchCriteria - 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(SearchResult result, int numResults, SearchCriteria searchCriteria)
result - response - searchCriteria - protected List<Product> getProducts(List<org.apache.solr.common.SolrDocument> responseDocuments)
response - protected List<Sku> getSkus(List<org.apache.solr.common.SolrDocument> responseDocuments)
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 getSolrTaggedFieldString(String indexField, String tag, SearchFacetRange range)
protected String getSolrFieldTag(String tagField, String tag, SearchFacetRange range)
protected String getSolrRangeString(String fieldName, BigDecimal minValue, BigDecimal maxValue)
protected String getSolrRangeFunctionString(BigDecimal minValue, BigDecimal maxValue)
minValue - maxValue - protected Map<String,SearchFacetDTO> getNamedFacetMap(List<SearchFacetDTO> facets, SearchCriteria searchCriteria)
facets - searchCriteria - protected org.apache.solr.client.solrj.SolrRequest.METHOD getSolrQueryMethod()
Copyright © 2021. All rights reserved.