Class CategoryProductSortSolrDocumentContributor
- java.lang.Object
-
- com.broadleafcommerce.search.index.catalog.solr.document.CategoryProductSortSolrDocumentContributor
-
- All Implemented Interfaces:
com.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>
public class CategoryProductSortSolrDocumentContributor extends Object implements com.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>
Component to pull Category / Product references off of the source data and index the category ID along with a sorting value.- Author:
- Kelly Tisdell (ktisdell)
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
PRODUCT_CATEGORY_SORT_JSON_PATH
-
Constructor Summary
Constructors Constructor Description CategoryProductSortSolrDocumentContributor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
canHandle(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
void
contributeInternal(com.broadleafcommerce.search.api.domain.Indexable<?> indexable, org.apache.solr.common.SolrInputDocument document, com.jayway.jsonpath.DocumentContext jsonContext, List<com.broadleafcommerce.search.api.domain.FieldDefinition> searchFields)
protected String
getUnsortedValue()
Returns the unsorted value.protected Map<String,String>
parseSortingMap(com.broadleafcommerce.search.api.domain.Indexable<?> indexable, com.jayway.jsonpath.DocumentContext jsonContext)
Attempts to parse the category sorting map from the JSON field, $.productSortingWithinCategories.
-
-
-
Field Detail
-
PRODUCT_CATEGORY_SORT_JSON_PATH
protected static final String PRODUCT_CATEGORY_SORT_JSON_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
contributeInternal
public void contributeInternal(com.broadleafcommerce.search.api.domain.Indexable<?> indexable, org.apache.solr.common.SolrInputDocument document, com.jayway.jsonpath.DocumentContext jsonContext, List<com.broadleafcommerce.search.api.domain.FieldDefinition> searchFields) throws com.broadleafcommerce.search.api.SearchIndexException
- Specified by:
contributeInternal
in interfacecom.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>
- Throws:
com.broadleafcommerce.search.api.SearchIndexException
-
canHandle
public boolean canHandle(com.broadleafcommerce.search.api.domain.Indexable<?> indexable)
- Specified by:
canHandle
in interfacecom.broadleafcommerce.search.index.core.document.DocumentBuilderContributor<org.apache.solr.common.SolrInputDocument>
-
getUnsortedValue
protected String getUnsortedValue()
Returns the unsorted value. By default, this is 'z'. The result MUST NOT be null.- Returns:
- the unsorted value
-
parseSortingMap
protected Map<String,String> parseSortingMap(com.broadleafcommerce.search.api.domain.Indexable<?> indexable, com.jayway.jsonpath.DocumentContext jsonContext)
Attempts to parse the category sorting map from the JSON field, $.productSortingWithinCategories. If an exception occurs here we log it and simply return an empty map. This default behavior allows us to avoid holding up indexing, continuing to build the document without proper sorting capabilities.- Parameters:
indexable
- theProduct
to be indexed.jsonContext
- the JSON context from which to parse the map.- Returns:
- a Map with category ID as the key and a lexicographical sort value as the value.
-
-