public class SolrSearchServiceImpl extends Object implements SearchService, org.springframework.beans.factory.DisposableBean
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
boostSearchResultsCategory |
protected org.springframework.core.env.Environment |
environment |
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 |
| 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
|
protected SearchContextDTO |
createSearchContextDTO() |
void |
destroy() |
protected boolean |
facetIsAvailable(SearchFacet facet,
Map<String,String[]> params)
Checks to see if the requiredFacets condition for a given facet is met.
|
protected void |
filterEmptyFacets(List<SearchFacetDTO> facets) |
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 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.
|
boolean |
isActive()
Determines whether or not the necessary configuration is in place
|
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.
|
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
protected ProductDao productDao
protected SkuDao skuDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected SolrHelperService shs
protected IndexFieldDao indexFieldDao
protected SolrSearchServiceExtensionManager extensionManager
@Autowired protected org.springframework.core.env.Environment environment
@Value(value="${solr.global.facets.category.search:false}")
protected boolean globalFacetsForCategorySearch
@Value(value="${solr.boost.category.results:false}")
protected boolean boostSearchResultsCategory
protected boolean shouldShowDebugQuery()
public 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 void filterEmptyFacets(List<SearchFacetDTO> facets)
protected 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 SearchContextDTO createSearchContextDTO()
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<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()
public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionpublic boolean isActive()
SearchServiceisActive in interface SearchServiceCopyright © 2022. All rights reserved.