Class DefaultSolrFacetContributor
java.lang.Object
com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
com.broadleafcommerce.search.provider.solr.DefaultSolrFacetContributor
- All Implemented Interfaces:
- SolrQueryContributor,- org.springframework.core.Ordered
- 
Field SummaryFieldsFields inherited from interface org.springframework.core.OrderedHIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
- 
Constructor SummaryConstructorsConstructorDescriptionDefaultSolrFacetContributor(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.rulesengine.expression.context.ExpressionContext expressionContext) 
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddRangedFacetExclusion(com.broadleafcommerce.search.api.domain.FieldDefinition facetField, org.apache.solr.client.solrj.SolrQuery solrQuery, String facetFieldName, List<com.broadleafcommerce.search.api.domain.Filter> filters) Update the facet range to exclude any active filters from the facet calculation.protected voidattachFacets(org.apache.solr.client.solrj.SolrQuery solrQuery, List<com.broadleafcommerce.search.api.domain.Filter> filters, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, String locale) Configure facets to enable facet responses for facets on this search type.protected voidattachRangedFacet(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.FieldDefinition field, List<com.broadleafcommerce.search.api.domain.Filter> filters, String locale) Attaches search facet ranges as Solr facet intervals.protected voidattachStandardFacet(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.FieldDefinition field, List<com.broadleafcommerce.search.api.domain.Filter> filters, String locale) Attaches a basic valued facet as a Solr facet field.protected StringbuildFacetFieldName(com.broadleafcommerce.search.api.domain.FieldDefinition field, String locale) Build the Solr field name for the facetable type on the field.protected StringbuildFacetFieldWithExclusion(com.broadleafcommerce.search.api.domain.FieldDefinition facetField, String facetFieldName, List<com.broadleafcommerce.search.api.domain.Filter> filters) Update a multi-select facet field name with tag to exclude any active filters from the facet calculation.protected String[]buildFacetRanges(com.broadleafcommerce.search.api.domain.FieldDefinition field) Build an array of the ranges which this field can be faceted on.buildFilterParamsMap(List<com.broadleafcommerce.search.api.domain.Filter> filters) Converts the filters in a set of filters to a key/value map to be used in Facet rule evaluation.protected voidcontributeInternal(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, String locale, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Customize the providedsolrQuerywith some additional behavior.protected List<com.broadleafcommerce.search.api.domain.FieldDefinition>filterFacetableFields(List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, List<com.broadleafcommerce.search.api.domain.Filter> filters) Determines whichFieldDefinitionswith facets are applicable to thisSearchRequest.protected booleanfilterMatchesFacetRule(com.broadleafcommerce.search.api.domain.Facet facet, Map<String, String> filterParams) Determines if theFacet'srule matches the filter parameters.protected com.broadleafcommerce.rulesengine.expression.context.ExpressionContextprotected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationServiceprotected com.broadleafcommerce.search.core.service.facet.SearchFacetUtils<com.broadleafcommerce.search.api.domain.Facet>protected com.broadleafcommerce.search.provider.solr.SolrFieldServicevoidsetSearchFacetUtils(com.broadleafcommerce.search.core.service.facet.SearchFacetUtils<com.broadleafcommerce.search.api.domain.Facet> searchFacetUtils) protected booleanshouldAttachFacet(com.broadleafcommerce.search.api.domain.Facet facet, Map<String, String> filterParams) Determine whether the facet should be included for the query based on current filters.protected booleanshouldContribute(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Determines if this contributor should run.Methods inherited from class com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributorcontributeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.search.provider.solr.SolrQueryContributorcontributeOnTypeAhead, getOrder, isTypeAheadRequest
- 
Field Details- 
EMPTY_MAP
 
- 
- 
Constructor Details- 
DefaultSolrFacetContributorpublic DefaultSolrFacetContributor(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService, com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.rulesengine.expression.context.ExpressionContext expressionContext) 
 
- 
- 
Method Details- 
contributeInternalprotected void contributeInternal(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable String locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from class:AbstractSolrQueryContributorCustomize the providedsolrQuerywith some additional behavior.- Specified by:
- contributeInternalin class- AbstractSolrQueryContributor
- Parameters:
- solrQuery- The query to customize
- searchRequest- The search query request
- fieldDefinitions- The fields to perform the search on
- page- Page information for page to retrieve for query
- properties- Additional properties for this query
- locale- The locale of this search
- context- The context information surrounding sandboxing/multitenant state
 
- 
attachFacetsprotected void attachFacets(org.apache.solr.client.solrj.SolrQuery solrQuery, List<com.broadleafcommerce.search.api.domain.Filter> filters, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, @Nullable String locale) Configure facets to enable facet responses for facets on this search type. An exclusion will be prepended for the names of the searchFilters active on the searchRequest, so that Facet counts are accurate in a multi-select scenario.- Parameters:
- solrQuery- Query to attach facet configuration
- filters- The filters from the search request.
- fieldDefinitions- All field definitions for the type being queried
- locale- (optional) the locale of the query
 
- 
filterFacetableFieldsprotected List<com.broadleafcommerce.search.api.domain.FieldDefinition> filterFacetableFields(List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, List<com.broadleafcommerce.search.api.domain.Filter> filters) Determines whichFieldDefinitionswith facets are applicable to thisSearchRequest.- Parameters:
- fieldDefinitions- The- FieldDefinitionsto examine.
- filters- The- Filterfilters to attach.
- Returns:
- A list of facetable FieldDefinitionsapplicable to this query.
 
- 
attachRangedFacetprotected void attachRangedFacet(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.FieldDefinition field, List<com.broadleafcommerce.search.api.domain.Filter> filters, @Nullable String locale) Attaches search facet ranges as Solr facet intervals.- Parameters:
- solrQuery- Query to attach facet field
- field- field with the ranged facet
- filters- The filters from the search request
- locale- (optional) the locale of the query
 
- 
buildFacetRangesBuild an array of the ranges which this field can be faceted on.- Parameters:
- field- the field with facet ranges
- Returns:
- an array of the ranges which this field can be faceted on
 
- 
addRangedFacetExclusionprotected void addRangedFacetExclusion(com.broadleafcommerce.search.api.domain.FieldDefinition facetField, org.apache.solr.client.solrj.SolrQuery solrQuery, String facetFieldName, List<com.broadleafcommerce.search.api.domain.Filter> filters) Update the facet range to exclude any active filters from the facet calculation.- Parameters:
- facetField- field with the facet
- solrQuery- the Solr query
- facetFieldName- the Solr name of the facet field to update
- filters- the filters to exclude
 
- 
attachStandardFacetprotected void attachStandardFacet(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.FieldDefinition field, List<com.broadleafcommerce.search.api.domain.Filter> filters, @Nullable String locale) Attaches a basic valued facet as a Solr facet field.- Parameters:
- solrQuery- Query to attach facet field
- field- field with the standard facet
- filters- The filters from the search request
- locale- (optional) the locale of the query
 
- 
buildFacetFieldWithExclusionprotected String buildFacetFieldWithExclusion(com.broadleafcommerce.search.api.domain.FieldDefinition facetField, String facetFieldName, List<com.broadleafcommerce.search.api.domain.Filter> filters) Update a multi-select facet field name with tag to exclude any active filters from the facet calculation.- Parameters:
- facetField- field with the facet
- facetFieldName- the Solr name of the facet field to update
- filters- The filters to exclude
 
- 
buildFacetFieldName@Nullable protected String buildFacetFieldName(com.broadleafcommerce.search.api.domain.FieldDefinition field, @Nullable String locale) Build the Solr field name for the facetable type on the field.- Parameters:
- field- the field to build the facet field name for
- locale- (optional) the locale of the query
- Returns:
- Solr field name for the facetable type on the field, or null if none is present
 
- 
buildFilterParamsMapprotected Map<String,String> buildFilterParamsMap(@Nullable List<com.broadleafcommerce.search.api.domain.Filter> filters) Converts the filters in a set of filters to a key/value map to be used in Facet rule evaluation. Note that this implementation only supports a single filter key/value comparison, and the first item in the filter's valuelisttakes precedence.- Parameters:
- filters- The filters to convert into a map.
- Returns:
- A key/value map of Filtervalues.
- See Also:
 
- 
shouldAttachFacetprotected boolean shouldAttachFacet(com.broadleafcommerce.search.api.domain.Facet facet, Map<String, String> filterParams) Determine whether the facet should be included for the query based on current filters.- Parameters:
- facet- the facet to consider
- filterParams- the current filters
- Returns:
- whether the facet should be included
 
- 
filterMatchesFacetRuleprotected boolean filterMatchesFacetRule(com.broadleafcommerce.search.api.domain.Facet facet, Map<String, String> filterParams) Determines if theFacet'srule matches the filter parameters.- Parameters:
- facet- The facet to evaluate with a non-null facet matching rule.
- filterParams- The filter parameters to evaluate against.
- Returns:
- true if rule matches, else false.
- Throws:
- IllegalArgumentException- if- Facet.getFacetRule()is null or empty.
 
- 
shouldContributeprotected boolean shouldContribute(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from class:AbstractSolrQueryContributorDetermines if this contributor should run.- Specified by:
- shouldContributein class- AbstractSolrQueryContributor
- Parameters:
- solrQuery- The query to customize
- searchRequest- The search query request
- page- Page information for page to retrieve for query
- properties- Additional properties for this query.
- context- The context information surrounding sandboxing/multitenant state
- Returns:
- whether this contributor should run
 
- 
defaultMap- Returns:
- Returns an empty, unmodifiable map.
 
- 
getSolrFieldServiceprotected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()
- 
getRuleEvaluationServiceprotected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService getRuleEvaluationService()
- 
getExpressionContextprotected com.broadleafcommerce.rulesengine.expression.context.ExpressionContext getExpressionContext()
- 
setSearchFacetUtils@Autowired public void setSearchFacetUtils(com.broadleafcommerce.search.core.service.facet.SearchFacetUtils<com.broadleafcommerce.search.api.domain.Facet> searchFacetUtils) - Since:
- 2.1.0-GA
 
- 
getSearchFacetUtilsprotected com.broadleafcommerce.search.core.service.facet.SearchFacetUtils<com.broadleafcommerce.search.api.domain.Facet> getSearchFacetUtils()- Since:
- 2.1.0-GA
 
 
-