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 ProductDao |
productDao |
protected SearchFacetDao |
searchFacetDao |
protected SolrHelperService |
shs |
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.SolrServer solrServer) |
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer) |
SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer,
org.apache.solr.client.solrj.SolrServer adminServer) |
SolrSearchServiceImpl(String solrServer) |
SolrSearchServiceImpl(String solrServer,
String reindexServer)
This constructor serves to mimic the one which takes in one
SolrServer argument. |
SolrSearchServiceImpl(String solrServer,
String reindexServer,
String adminServer)
This constructor serves to mimic the one which takes in one
SolrServer argument. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet() |
protected void |
appendFieldToQuery(StringBuilder queryBuilder,
Field currentField) |
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() |
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.
|
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)
Performs a search for search results in the given category, taking into consideration the SearchCriteria
This method will return search results that are in any sub-level of a given category.
|
SearchResult |
findSearchResultsByCategoryAndQuery(Category category,
String query,
SearchCriteria searchCriteria)
Performs a search for search results in the given category for the given query, taking into consideration
the SearchCriteria
|
SearchResult |
findSearchResultsByQuery(String query,
SearchCriteria searchCriteria)
Performs a search for search results across all categories for the given query, taking into consideration
the SearchCriteria
|
List<SearchFacetDTO> |
getCategoryFacets(Category category)
Gets all available facets for a given category
|
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 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
|
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 Map<String,String> |
getSolrFieldKeyMap(SearchCriteria searchCriteria) |
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
protected ProductDao productDao
protected SkuDao skuDao
protected FieldDao fieldDao
protected SearchFacetDao searchFacetDao
protected SolrHelperService shs
protected SolrIndexService solrIndexService
protected SolrSearchServiceExtensionManager extensionManager
protected String solrHomePath
public SolrSearchServiceImpl(String solrServer) throws IOException, ParserConfigurationException, SAXException
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer)
public SolrSearchServiceImpl(String solrServer, String reindexServer) throws IOException, ParserConfigurationException, SAXException
SolrServer 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
SolrServer 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.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer)
public SolrSearchServiceImpl(org.apache.solr.client.solrj.SolrServer solrServer,
org.apache.solr.client.solrj.SolrServer reindexServer,
org.apache.solr.client.solrj.SolrServer 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)public SearchResult findSearchResultsByCategory(Category category, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResultsByCategory in interface SearchServiceServiceExceptionSearchService.findExplicitSearchResultsByCategory(Category, SearchCriteria)public SearchResult findSearchResultsByQuery(String query, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResultsByQuery in interface SearchServiceServiceExceptionpublic SearchResult findSearchResultsByCategoryAndQuery(Category category, String query, SearchCriteria searchCriteria) throws ServiceException
SearchServicefindSearchResultsByCategoryAndQuery in interface SearchServiceServiceExceptionpublic String getLocalePrefix()
protected String buildQueryFieldsString()
protected void appendFieldToQuery(StringBuilder queryBuilder, Field currentField)
@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
qualifiedSolrQuery - facets - searchCriteria - ServiceExceptionprotected 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> 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 Map<String,String> getSolrFieldKeyMap(SearchCriteria searchCriteria)
searchCriteria - protected org.apache.solr.client.solrj.SolrRequest.METHOD getSolrQueryMethod()
Copyright © 2017. All rights reserved.