Class DefaultSolrFilterContributor
- java.lang.Object
-
- com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
-
- com.broadleafcommerce.search.provider.solr.DefaultSolrFilterContributor
-
- All Implemented Interfaces:
SolrQueryContributor
,org.springframework.core.Ordered
public class DefaultSolrFilterContributor extends AbstractSolrQueryContributor
-
-
Constructor Summary
Constructors Constructor Description DefaultSolrFilterContributor(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
attachFilters(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 query for Solr with necessary filtersprotected String
buildFilterQuery(@NonNull com.broadleafcommerce.search.api.domain.Filter searchFilter, String fieldName, @NonNull com.broadleafcommerce.search.api.domain.FieldDefinition fieldDefinition)
Create the filter query described by the searchFilter for the given field.protected 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, String locale, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Customize the providedsolrQuery
with some additional behavior.boolean
contributeOnTypeAhead()
protected void
decodeFilterValues(com.broadleafcommerce.search.api.domain.Filter filter)
Decodes the givenFilter.getValues()
.protected Optional<String>
getFilterQuery(com.broadleafcommerce.search.api.domain.Filter filter, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fields, String locale)
Build the filter query to attach to the Solr query, if it matches an existing field.protected com.broadleafcommerce.search.provider.solr.SolrFieldService
getSolrFieldService()
protected 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, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Determines if this contributor should run.-
Methods inherited from class com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
contribute
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.broadleafcommerce.search.provider.solr.SolrQueryContributor
getOrder, isTypeAheadRequest
-
-
-
-
Method Detail
-
contributeInternal
protected 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, @Nullable com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable String locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from class:AbstractSolrQueryContributor
Customize the providedsolrQuery
with some additional behavior.- Specified by:
contributeInternal
in classAbstractSolrQueryContributor
- Parameters:
solrQuery
- The query to customizesearchRequest
- The search query requestfieldDefinitions
- The fields to perform the search onpage
- Page information for page to retrieve for queryproperties
- Additional properties for this querylocale
- The locale of this searchcontext
- The context information surrounding sandboxing/multitenant state
-
attachFilters
protected void attachFilters(org.apache.solr.client.solrj.SolrQuery solrQuery, @Nullable List<com.broadleafcommerce.search.api.domain.Filter> filters, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, @Nullable String locale)
Configure query for Solr with necessary filters- Parameters:
solrQuery
- Query to attach filters ontofilters
- The filters to apply to the queryfieldDefinitions
- All field definitions for the type being queriedlocale
- (optional) the locale of the query
-
decodeFilterValues
protected void decodeFilterValues(com.broadleafcommerce.search.api.domain.Filter filter)
Decodes the givenFilter.getValues()
.- Parameters:
filter
- theFilter
to decode
-
getFilterQuery
protected Optional<String> getFilterQuery(com.broadleafcommerce.search.api.domain.Filter filter, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fields, @Nullable String locale)
Build the filter query to attach to the Solr query, if it matches an existing field.- Parameters:
filter
- the filter to convert to a Solr filterfields
- All field definitions for the type being queriedlocale
- (optional) the locale of the query- Returns:
- if present, the filter query to attach to the Solr query
-
buildFilterQuery
protected String buildFilterQuery(@NonNull @NonNull com.broadleafcommerce.search.api.domain.Filter searchFilter, String fieldName, @NonNull @NonNull com.broadleafcommerce.search.api.domain.FieldDefinition fieldDefinition)
Create the filter query described by the searchFilter for the given field. A tag will be generated for the searchFilter name and prepended to the filter query to enable excluding it for the purpose of generating accurate Facet count results.- Parameters:
searchFilter
- The search filter to build as a Solr queryfieldName
- The typed Solr name of the field on which to filterfieldDefinition
- TheFieldDefinition
matching theFilter
by name- Returns:
- Tagged Solr filter query
-
shouldContribute
protected boolean shouldContribute(org.apache.solr.client.solrj.SolrQuery solrQuery, com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from class:AbstractSolrQueryContributor
Determines if this contributor should run.- Specified by:
shouldContribute
in classAbstractSolrQueryContributor
- Parameters:
solrQuery
- The query to customizesearchRequest
- The search query requestpage
- Page information for page to retrieve for queryproperties
- Additional properties for this query.context
- The context information surrounding sandboxing/multitenant state- Returns:
- whether this contributor should run
-
contributeOnTypeAhead
public boolean contributeOnTypeAhead()
- Returns:
- Should this contributor be executed on TypeAhead requests?
-
getSolrFieldService
protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()
-
-