Class TypeAheadFacetFieldsPreProcessor

  • All Implemented Interfaces:
    com.broadleafcommerce.search.core.service.TypeAheadPreProcessor<org.apache.solr.client.solrj.SolrQuery>, org.springframework.core.Ordered

    public class TypeAheadFacetFieldsPreProcessor
    extends Object
    implements com.broadleafcommerce.search.core.service.TypeAheadPreProcessor<org.apache.solr.client.solrj.SolrQuery>

    This pre-processor is responsible for handling suggestion configurations marked as faceted. This will set the desired Facet fields on the SolrQuery, as well as limit the facet results, if a result limit is set.

    • Field Summary

      • Fields inherited from interface org.springframework.core.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Constructor Summary

      Constructors 
      Constructor Description
      TypeAheadFacetFieldsPreProcessor​(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 Map<String,​Integer> getFacetFieldsWithLimits​(List<com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration> typeAheadSuggestionConfigurations, String locale)
      Returns a map of faceted fields configured for the type ahead suggestions, along with the limit on their results to return.
      protected com.broadleafcommerce.search.core.service.locale.LocaleHelper getLocaleHelper()  
      int getOrder()  
      protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()  
      protected boolean isLimitedFacet​(Map<String,​Integer> facetFields, String field)
      Check whether the matching facet field should have limited results.
      void preProcess​(org.apache.solr.client.solrj.SolrQuery query, com.broadleafcommerce.search.api.domain.typeahead.TypeAheadRequest typeAheadRequest, com.broadleafcommerce.search.api.domain.TypeAheadConfiguration typeAheadConfiguration, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)  
      protected void setFacetFields​(org.apache.solr.client.solrj.SolrQuery query, com.broadleafcommerce.search.api.domain.TypeAheadConfiguration typeAheadConfiguration, String locale)
      Configure faceting for fields on the type ahead query.
    • Constructor Detail

      • TypeAheadFacetFieldsPreProcessor

        public TypeAheadFacetFieldsPreProcessor​(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService,
                                                com.broadleafcommerce.search.core.service.locale.LocaleHelper localeHelper)
    • Method Detail

      • preProcess

        public void preProcess​(org.apache.solr.client.solrj.SolrQuery query,
                               com.broadleafcommerce.search.api.domain.typeahead.TypeAheadRequest typeAheadRequest,
                               com.broadleafcommerce.search.api.domain.TypeAheadConfiguration typeAheadConfiguration,
                               com.broadleafcommerce.search.core.service.SearchRequestProperties properties,
                               @Nullable
                               com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Specified by:
        preProcess in interface com.broadleafcommerce.search.core.service.TypeAheadPreProcessor<org.apache.solr.client.solrj.SolrQuery>
      • setFacetFields

        protected void setFacetFields​(org.apache.solr.client.solrj.SolrQuery query,
                                      com.broadleafcommerce.search.api.domain.TypeAheadConfiguration typeAheadConfiguration,
                                      @Nullable
                                      String locale)
        Configure faceting for fields on the type ahead query.
        Parameters:
        query - the Solr query to search on
        typeAheadConfiguration - the configuration with suggestion fields for faceting
        locale - (optional) the locale of the query
      • getFacetFieldsWithLimits

        protected Map<String,​Integer> getFacetFieldsWithLimits​(List<com.broadleafcommerce.search.api.domain.TypeAheadSuggestionConfiguration> typeAheadSuggestionConfigurations,
                                                                     @Nullable
                                                                     String locale)
        Returns a map of faceted fields configured for the type ahead suggestions, along with the limit on their results to return.
        Parameters:
        typeAheadSuggestionConfigurations - the configured suggestions for type ahead
        locale - (optional) the locale of the query
        Returns:
        map of faceted fields and their result limits
      • isLimitedFacet

        protected boolean isLimitedFacet​(Map<String,​Integer> facetFields,
                                         String field)
        Check whether the matching facet field should have limited results.
        Parameters:
        facetFields - map of faceted fields and their result limits
        field - field to check for limit
        Returns:
        whether the matching facet field should have limited results
      • getOrder

        public int getOrder()
        Specified by:
        getOrder in interface org.springframework.core.Ordered
      • getSolrFieldService

        protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()
      • getLocaleHelper

        protected com.broadleafcommerce.search.core.service.locale.LocaleHelper getLocaleHelper()