Class TypeAheadSuggestionFieldsPostProcessor
- java.lang.Object
-
- com.broadleafcommerce.search.provider.solr.typeahead.postprocessors.TypeAheadSuggestionFieldsPostProcessor
-
- All Implemented Interfaces:
com.broadleafcommerce.search.core.service.TypeAheadPostProcessor<org.apache.solr.client.solrj.response.QueryResponse>
,org.springframework.core.Ordered
public class TypeAheadSuggestionFieldsPostProcessor extends Object implements com.broadleafcommerce.search.core.service.TypeAheadPostProcessor<org.apache.solr.client.solrj.response.QueryResponse>
This PostProcessor is responsible for building recommended results on a TypeAhead query. Common use-cases are recommended categories or specific products. SeeTypeAheadSuggestionConfiguration
for more information.
-
-
Field Summary
Fields Modifier and Type Field Description static String
RESULT_COUNT
-
Constructor Summary
Constructors Constructor Description TypeAheadSuggestionFieldsPostProcessor(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService, com.broadleafcommerce.search.core.service.locale.LocaleHelper localeHelper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addFacetValues(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, com.broadleafcommerce.search.api.domain.SuggestionField suggestionField, org.apache.solr.client.solrj.response.FacetField facetField)
Populate the facet counts and names in the suggestion results for the field.protected void
buildFacetResponse(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, String locale, org.apache.solr.client.solrj.response.QueryResponse queryResponse)
Build facet response for the type ahead response.protected void
buildSuggestionFields(com.broadleafcommerce.search.api.domain.typeahead.TypeAheadResponse response, String locale, List<com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration> configs, org.apache.solr.client.solrj.response.QueryResponse queryResponse)
Populate the type-ahead suggestion items or facets for each type-ahead suggestion configuration.protected Map<String,Object>
buildSuggestionMap(org.apache.solr.common.SolrDocument result, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, String locale)
Build a suggestion result object for a type ahead result.protected void
buildSuggestions(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, String locale, org.apache.solr.client.solrj.response.QueryResponse queryResponse)
Build suggestion results for the type ahead response.protected com.broadleafcommerce.search.core.service.locale.LocaleHelper
getLocaleHelper()
int
getOrder()
protected com.broadleafcommerce.search.provider.solr.SolrFieldService
getSolrFieldService()
protected boolean
notReachedSizeLimit(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config)
Check whether the suggestion results have been fully populated to their maximum size.void
postProcess(org.apache.solr.client.solrj.response.QueryResponse queryResponse, com.broadleafcommerce.search.api.domain.typeahead.TypeAheadResponse response, com.broadleafcommerce.search.api.domain.typeahead.TypeAheadRequest request, com.broadleafcommerce.search.api.domain.TypeAheadConfiguration configuration, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
protected boolean
shouldProcess(org.apache.solr.client.solrj.response.QueryResponse queryResponse, com.broadleafcommerce.search.api.domain.TypeAheadConfiguration typeAheadConfiguration)
Whether suggestion fields should be processed.
-
-
-
Field Detail
-
RESULT_COUNT
public static final String RESULT_COUNT
- See Also:
- Constant Field Values
-
-
Method Detail
-
postProcess
public void postProcess(org.apache.solr.client.solrj.response.QueryResponse queryResponse, com.broadleafcommerce.search.api.domain.typeahead.TypeAheadResponse response, com.broadleafcommerce.search.api.domain.typeahead.TypeAheadRequest request, com.broadleafcommerce.search.api.domain.TypeAheadConfiguration configuration, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
- Specified by:
postProcess
in interfacecom.broadleafcommerce.search.core.service.TypeAheadPostProcessor<org.apache.solr.client.solrj.response.QueryResponse>
-
shouldProcess
protected boolean shouldProcess(org.apache.solr.client.solrj.response.QueryResponse queryResponse, com.broadleafcommerce.search.api.domain.TypeAheadConfiguration typeAheadConfiguration)
Whether suggestion fields should be processed. Checks for existingTypeAheadConfiguration.getTypeAheadSuggestionConfigurations()
andQueryResponse.getResults()
.- Parameters:
queryResponse
- Solr query response to processtypeAheadConfiguration
- type ahead configuration for the type ahead query- Returns:
- whether type ahead suggestion fields should be processed
-
buildSuggestionFields
protected void buildSuggestionFields(com.broadleafcommerce.search.api.domain.typeahead.TypeAheadResponse response, @Nullable String locale, List<com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration> configs, org.apache.solr.client.solrj.response.QueryResponse queryResponse)
Populate the type-ahead suggestion items or facets for each type-ahead suggestion configuration.- Parameters:
response
- TypeAhead response to processlocale
- (optional) the locale of the queryconfigs
- the configured type ahead suggestion groupsqueryResponse
- Solr query response
-
buildFacetResponse
protected void buildFacetResponse(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, @Nullable String locale, org.apache.solr.client.solrj.response.QueryResponse queryResponse)
Build facet response for the type ahead response.- Parameters:
suggestions
- the suggested results for each field matched by the queryconfig
- the type ahead configurationlocale
- (optional) the locale of the queryqueryResponse
- Solr query response
-
addFacetValues
protected void addFacetValues(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, com.broadleafcommerce.search.api.domain.SuggestionField suggestionField, org.apache.solr.client.solrj.response.FacetField facetField)
Populate the facet counts and names in the suggestion results for the field.- Parameters:
suggestions
- the suggested results for each field matched by the queryconfig
- the type ahead configurationsuggestionField
- the field in the suggested result matching the queryfacetField
- the facet response for the suggestion field
-
buildSuggestions
protected void buildSuggestions(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, @Nullable String locale, org.apache.solr.client.solrj.response.QueryResponse queryResponse)
Build suggestion results for the type ahead response.- Parameters:
suggestions
- the suggested results for each field matched by the queryconfig
- the type ahead configurationlocale
- (optional) the locale of the queryqueryResponse
- Solr query response
-
buildSuggestionMap
protected Map<String,Object> buildSuggestionMap(org.apache.solr.common.SolrDocument result, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config, @Nullable String locale)
Build a suggestion result object for a type ahead result.- Parameters:
result
- the document result for the type ahead searchconfig
- the suggestion configuration indicating which fields to return in the resultlocale
- (optional) the locale of the query- Returns:
- a suggestion result object for a type ahead result
-
notReachedSizeLimit
protected boolean notReachedSizeLimit(Map<String,List<Map<String,Object>>> suggestions, com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration config)
Check whether the suggestion results have been fully populated to their maximum size.- Parameters:
suggestions
- the suggestion resultsconfig
- suggestion configuration including maximum number of suggestion results- Returns:
- whether suggestion resutls are fully populated
-
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
-
getSolrFieldService
protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()
-
getLocaleHelper
protected com.broadleafcommerce.search.core.service.locale.LocaleHelper getLocaleHelper()
-
-