public class SolrSearchServiceImpl extends Object implements SearchService, org.springframework.beans.factory.InitializingBean, 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 String |
siteAliasBase |
protected String |
siteCollectionBase |
protected boolean |
siteCollections |
protected SkuDao |
skuDao |
protected String |
solrCloudConfigName |
protected int |
solrCloudNumShards |
protected String |
solrHomePath |
protected SolrIndexService |
solrIndexService |
protected boolean |
useSku |
| Constructor and Description |
|---|
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrClient solrServer) |
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrClient solrServer,
org.apache.solr.client.solrj.SolrClient reindexServer) |
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrClient solrServer,
org.apache.solr.client.solrj.SolrClient reindexServer,
org.apache.solr.client.solrj.SolrClient adminServer) |
SolrSearchServiceImpl(String solrServer) |
SolrSearchServiceImpl(String solrServer,
String reindexServer)
This constructor serves to mimic the one which takes in one
SolrClient argument. |
SolrSearchServiceImpl(String solrServer,
String reindexServer,
String adminServer)
This constructor serves to mimic the one which takes in one
SolrClient argument. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
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)
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 void |
buildSolrCoreDirectories(String solrServer)
This creates the proper directories and writes the correct properties files for Solr to run in embedded mode.
|
void |
copyConfigToSolrHome(InputStream configIs,
File destFile) |
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.
|
String |
getSolrHomePath() |
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 void |
sortFacetResults(Map<String,SearchFacetDTO> namedFacetMap)
Invoked to sort the facet results.
|
@Value(value="${solr.index.use.sku}")
protected boolean useSku
@Value(value="${solr.cloud.configName}")
protected String solrCloudConfigName
@Value(value="${solr.cloud.defaultNumShards}")
protected int solrCloudNumShards
@Value(value="${solr.index.site.collections:false}")
protected boolean siteCollections
@Value(value="${solr.index.site.alias.name:site}")
protected String siteAliasBase
@Value(value="${solr.index.site.collection.name:blcSite}")
protected String siteCollectionBase
protected ProductDao productDao
protected SkuDao skuDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected SolrHelperService shs
protected SolrIndexService solrIndexService
protected IndexFieldDao indexFieldDao
protected SolrSearchServiceExtensionManager extensionManager
protected String solrHomePath
@Value(value="${solr.global.facets.category.search:false}")
protected boolean globalFacetsForCategorySearch
public SolrSearchServiceImpl(String solrServer) throws IOException, ParserConfigurationException, SAXException
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrClient solrServer)
public SolrSearchServiceImpl(String solrServer, String reindexServer) throws IOException, ParserConfigurationException, SAXException
SolrClient argument.
By having this and then simply disregarding the second parameter, we can more easily support 2-core
Solr configurations that use embedded/standalone per environment.solrServer - reindexServer - SAXExceptionParserConfigurationExceptionIOExceptionpublic SolrSearchServiceImpl(String solrServer, String reindexServer, String adminServer) throws IOException, ParserConfigurationException, SAXException
SolrClient argument.
By having this and then simply disregarding the second and third parameters, we can more easily support 2-core
Solr configurations that use embedded/standalone per environment, along with an admin server.solrServer - reindexServer - SAXExceptionParserConfigurationExceptionIOExceptionpublic SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrClient solrServer,
org.apache.solr.client.solrj.SolrClient reindexServer)
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrClient solrServer,
org.apache.solr.client.solrj.SolrClient reindexServer,
org.apache.solr.client.solrj.SolrClient adminServer)
public String getSolrHomePath()
public void copyConfigToSolrHome(InputStream configIs, File destFile) throws IOException
IOExceptionprotected void buildSolrCoreDirectories(String solrServer) throws IOException
solrServer - 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 afterPropertiesSet()
throws Exception
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanExceptionpublic void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionpublic 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)
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(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 © 2016. All rights reserved.