Class CategoryProductSortQueryContributor

  • All Implemented Interfaces:
    com.broadleafcommerce.search.provider.solr.IndexableTypeSolrQueryContributor, com.broadleafcommerce.search.provider.solr.SolrQueryContributor, org.springframework.core.Ordered

    public class CategoryProductSortQueryContributor
    extends com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
    implements com.broadleafcommerce.search.provider.solr.IndexableTypeSolrQueryContributor
    Component to provide implicit sorting based on product's sorting values for each category. This requires that the Solr field(s) that we're sorting by have the property sortMissingLast="true" in the Solr schema. The default field for this component uses a String field (*_s), which is, by default, set to sort missing last.
    Author:
    Kelly Tisdell (ktisdell)
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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)  
      boolean contributeOnTypeAhead()  
      protected String getCategoryProductSortFieldName​(String categoryId)
      Constructs a field name to sort by using the category Id.
      com.broadleafcommerce.search.api.type.IndexableType getIndexableType()  
      int getOrder()  
      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)  
      • Methods inherited from class com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor

        contribute
      • Methods inherited from interface com.broadleafcommerce.search.provider.solr.SolrQueryContributor

        contribute, isTypeAheadRequest
    • Field Detail

      • CATEGORY_IDS_FILTER_NAME

        protected static final String CATEGORY_IDS_FILTER_NAME
        This is the default name of the Category filter.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CategoryProductSortQueryContributor

        public CategoryProductSortQueryContributor()
    • Method Detail

      • getIndexableType

        public com.broadleafcommerce.search.api.type.IndexableType getIndexableType()
        Specified by:
        getIndexableType in interface com.broadleafcommerce.search.provider.solr.IndexableTypeSolrQueryContributor
      • 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,
                                          com.broadleafcommerce.search.core.service.SearchRequestProperties properties,
                                          String locale,
                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Specified by:
        contributeInternal in class com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
      • shouldContribute

        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)
        Specified by:
        shouldContribute in class com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
      • contributeOnTypeAhead

        public boolean contributeOnTypeAhead()
        Specified by:
        contributeOnTypeAhead in interface com.broadleafcommerce.search.provider.solr.SolrQueryContributor
      • getOrder

        public int getOrder()
        Specified by:
        getOrder in interface org.springframework.core.Ordered
        Specified by:
        getOrder in interface com.broadleafcommerce.search.provider.solr.SolrQueryContributor
      • getCategoryProductSortFieldName

        protected String getCategoryProductSortFieldName​(String categoryId)
        Constructs a field name to sort by using the category Id. NOTE: This functionality depends on the Solr having sortMissingLast="true" for this field or dynamic field ('*_s', by default).
        Returns:
        a sort field name