Class CategoryProductSortQueryContributor
- java.lang.Object
-
- com.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
-
- com.broadleafcommerce.search.catalog.solr.query.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)
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
CATEGORY_IDS_FILTER_NAME
This is the default name of the Category filter.protected static String
DEFAULT_IMPLICIT_SORT_CLAUSE
protected static int
DEFAULT_PRECEDENCE
-
Constructor Summary
Constructors Constructor Description CategoryProductSortQueryContributor()
-
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
-
-
-
-
Field Detail
-
DEFAULT_PRECEDENCE
protected static final int DEFAULT_PRECEDENCE
- See Also:
- Constant Field Values
-
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
-
DEFAULT_IMPLICIT_SORT_CLAUSE
protected static final String DEFAULT_IMPLICIT_SORT_CLAUSE
- See Also:
- Constant Field Values
-
-
Method Detail
-
getIndexableType
public com.broadleafcommerce.search.api.type.IndexableType getIndexableType()
- Specified by:
getIndexableType
in interfacecom.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 classcom.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 classcom.broadleafcommerce.search.provider.solr.AbstractSolrQueryContributor
-
contributeOnTypeAhead
public boolean contributeOnTypeAhead()
- Specified by:
contributeOnTypeAhead
in interfacecom.broadleafcommerce.search.provider.solr.SolrQueryContributor
-
getOrder
public int getOrder()
- Specified by:
getOrder
in interfaceorg.springframework.core.Ordered
- Specified by:
getOrder
in interfacecom.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
-
-