Class AbstractSolrSearchServiceExtensionHandler
java.lang.Object
org.broadleafcommerce.common.extension.AbstractExtensionHandler
org.broadleafcommerce.core.search.service.solr.AbstractSolrSearchServiceExtensionHandler
- All Implemented Interfaces:
org.broadleafcommerce.common.extension.ExtensionHandler,SolrSearchServiceExtensionHandler
- Direct Known Subclasses:
I18nSolrSearchServiceExtensionHandler
public abstract class AbstractSolrSearchServiceExtensionHandler
extends org.broadleafcommerce.common.extension.AbstractExtensionHandler
implements SolrSearchServiceExtensionHandler
Implementors of the SolrSearchServiceExtensionHandler interface should extend this class so that if
additional extension points are added which they don't care about, their code will not need to be
modified.
- Author:
- bpolster
-
Field Summary
Fields inherited from class org.broadleafcommerce.common.extension.AbstractExtensionHandler
enabled, priority -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.broadleafcommerce.common.extension.ExtensionResultStatusTypeaddAdditionalCategoryIds(Category category, SearchCriteria searchCriteria, List<Long> categoryIds) Adds any additional category ids to filter by when category browsing or searching.org.broadleafcommerce.common.extension.ExtensionResultStatusTypeattachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto) Deprecated.org.broadleafcommerce.common.extension.ExtensionResultStatusTypeattachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto, SearchCriteria searchCriteria) Attaches the given dto to the given query, if possibleorg.broadleafcommerce.common.extension.ExtensionResultStatusTypeattachSortField(org.apache.solr.client.solrj.SolrQuery solrQuery, String requestedSortFieldName, org.apache.solr.client.solrj.SolrQuery.ORDER order) Attaches the sort field, if able, to the givenSolrQuery.org.broadleafcommerce.common.extension.ExtensionResultStatusTypebatchFetchCatalogData(List<Product> products) Batch fetch important collections for the entire list of products in single batch fetch queries.org.broadleafcommerce.common.extension.ExtensionResultStatusTypebuildActiveFacetFilter(FieldEntity entityType, String solrKey, String[] selectedValues, List<String> valueStrings) Deprecated.org.broadleafcommerce.common.extension.ExtensionResultStatusTypebuildActiveFacetFilter(SearchFacet facet, String[] selectedValues, List<String> valueStrings) Builds the active facet filter query string for the given entity type and values.org.broadleafcommerce.common.extension.ExtensionResultStatusTypebuildPrefixListForIndexField(IndexField field, FieldType fieldType, List<String> prefixList) Returns a prefix if required for the passed in searchable field.org.broadleafcommerce.common.extension.ExtensionResultStatusTypefilterSearchFacetRanges(SearchFacetDTO dto, List<SearchFacetRange> ranges) Builds the search facet ranges for the provided dto.org.broadleafcommerce.common.extension.ExtensionResultStatusTypegetCategoryId(Category category, Long[] returnContainer) In certain scenarios, the requested category id might not be the one that should be used in Solr.org.broadleafcommerce.common.extension.ExtensionResultStatusTypegetCategorySearchFacets(Category category, List<SearchFacet> searchFacets) Populates the List of SearchFacet's for the given Category, or else returns NOT_HANDLEDorg.broadleafcommerce.common.extension.ExtensionResultStatusTypegetPropertyNameForIndexField(IndexField field, FieldType fieldType, String prefix, org.broadleafcommerce.common.extension.ExtensionResultHolder<String> erh) Extension point to allow overriding the way the property name for an index field with the given field type and prefix is built.org.broadleafcommerce.common.extension.ExtensionResultStatusTypegetQueryField(org.apache.solr.client.solrj.SolrQuery query, SearchCriteria searchCriteria, IndexFieldType indexFieldType, org.broadleafcommerce.common.extension.ExtensionResultHolder<List<String>> queryFieldsResult) Finds and adds the query fields for the given search field and searchable field type.org.broadleafcommerce.common.extension.ExtensionResultStatusTypegetSearchableIndexFields(List<IndexField> fields) Populated the List of searchable IndexField's that will be used in building the query fields (qf) for a Solr query.org.broadleafcommerce.common.extension.ExtensionResultStatusTypegetSearchFacets(List<SearchFacet> searchFacets) Populates the List of SearchFacet's, or else returns NOT_HANDLEDorg.broadleafcommerce.common.extension.ExtensionResultStatusTypemodifySearchResults(List<org.apache.solr.common.SolrDocument> responseDocuments, List<Product> products) Modifies the product search results from a Solr queryorg.broadleafcommerce.common.extension.ExtensionResultStatusTypemodifySolrQuery(org.apache.solr.client.solrj.SolrQuery query, String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) Provides an extension point to modify the SolrQuery.org.broadleafcommerce.common.extension.ExtensionResultStatusTypemodifySolrQuery(SearchContextDTO context, org.apache.solr.client.solrj.SolrQuery query, String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) Provides an extension point to modify the SolrQuery.org.broadleafcommerce.common.extension.ExtensionResultStatusTypesetFacetResults(Map<String, SearchFacetDTO> namedFacetMap, org.apache.solr.client.solrj.response.QueryResponse response) Attaches any additional facet results to the namedFacetMap if they exist.Methods inherited from class org.broadleafcommerce.common.extension.AbstractExtensionHandler
getPriority, isEnabled, setEnabled, setPriorityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.broadleafcommerce.common.extension.ExtensionHandler
getPriority, isEnabled
-
Constructor Details
-
AbstractSolrSearchServiceExtensionHandler
public AbstractSolrSearchServiceExtensionHandler()
-
-
Method Details
-
buildPrefixListForIndexField
public org.broadleafcommerce.common.extension.ExtensionResultStatusType buildPrefixListForIndexField(IndexField field, FieldType fieldType, List<String> prefixList) Description copied from interface:SolrSearchServiceExtensionHandlerReturns a prefix if required for the passed in searchable field.- Specified by:
buildPrefixListForIndexFieldin interfaceSolrSearchServiceExtensionHandler
-
filterSearchFacetRanges
public org.broadleafcommerce.common.extension.ExtensionResultStatusType filterSearchFacetRanges(SearchFacetDTO dto, List<SearchFacetRange> ranges) Description copied from interface:SolrSearchServiceExtensionHandlerBuilds the search facet ranges for the provided dto.- Specified by:
filterSearchFacetRangesin interfaceSolrSearchServiceExtensionHandler
-
modifySolrQuery
public org.broadleafcommerce.common.extension.ExtensionResultStatusType modifySolrQuery(org.apache.solr.client.solrj.SolrQuery query, String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) Description copied from interface:SolrSearchServiceExtensionHandlerProvides an extension point to modify the SolrQuery.- Specified by:
modifySolrQueryin interfaceSolrSearchServiceExtensionHandler
-
modifySolrQuery
public org.broadleafcommerce.common.extension.ExtensionResultStatusType modifySolrQuery(SearchContextDTO context, org.apache.solr.client.solrj.SolrQuery query, String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) Description copied from interface:SolrSearchServiceExtensionHandlerProvides an extension point to modify the SolrQuery.- Specified by:
modifySolrQueryin interfaceSolrSearchServiceExtensionHandler
-
getQueryField
public org.broadleafcommerce.common.extension.ExtensionResultStatusType getQueryField(org.apache.solr.client.solrj.SolrQuery query, SearchCriteria searchCriteria, IndexFieldType indexFieldType, org.broadleafcommerce.common.extension.ExtensionResultHolder<List<String>> queryFieldsResult) Description copied from interface:SolrSearchServiceExtensionHandlerFinds and adds the query fields for the given search field and searchable field type. This method should only ADD to the list within the queryFieldsResult parameters.
Most implementations of this will need to invoke
SolrHelperService.getPropertyNameForIndexField(IndexField, FieldType)in order to return the right value to populate in the queryFieldsResult. If the returned result isExtensionResultStatusType.NOT_HANDLEDthen the default behavior is to only do that.- Specified by:
getQueryFieldin interfaceSolrSearchServiceExtensionHandlerindexFieldType- the field type of the fieldqueryFieldsResult- the binding result that contains the list of query fields, only add to this @return the result of the handler, if NOT_HANDLED, then no query fields were added
-
modifySearchResults
public org.broadleafcommerce.common.extension.ExtensionResultStatusType modifySearchResults(List<org.apache.solr.common.SolrDocument> responseDocuments, List<Product> products) Description copied from interface:SolrSearchServiceExtensionHandlerModifies the product search results from a Solr query
The parameters passed into this method should be assumed to be sorted identically and match one to one.
- Specified by:
modifySearchResultsin interfaceSolrSearchServiceExtensionHandler- Parameters:
responseDocuments- the response documents from Solrproducts- the products that tie to the response documents- Returns:
- the result of the handler, if NOT_HANDLED, then no changes where made
-
getSearchFacets
public org.broadleafcommerce.common.extension.ExtensionResultStatusType getSearchFacets(List<SearchFacet> searchFacets) Description copied from interface:SolrSearchServiceExtensionHandlerPopulates the List of SearchFacet's, or else returns NOT_HANDLED- Specified by:
getSearchFacetsin interfaceSolrSearchServiceExtensionHandler- Parameters:
searchFacets- the List to populate- Returns:
- the result of the handler
-
attachFacet
@Deprecated public org.broadleafcommerce.common.extension.ExtensionResultStatusType attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto) Deprecated.Description copied from interface:SolrSearchServiceExtensionHandlerAttaches the given dto to the given query, if possible- Specified by:
attachFacetin interfaceSolrSearchServiceExtensionHandler- Parameters:
query- the SolrQuery to attach the facet to- Returns:
- the result of the handler
-
attachFacet
public org.broadleafcommerce.common.extension.ExtensionResultStatusType attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto, SearchCriteria searchCriteria) Description copied from interface:SolrSearchServiceExtensionHandlerAttaches the given dto to the given query, if possible- Specified by:
attachFacetin interfaceSolrSearchServiceExtensionHandler- Parameters:
query- the SolrQuery to attach the facet to- Returns:
- the result of the handler
-
setFacetResults
public org.broadleafcommerce.common.extension.ExtensionResultStatusType setFacetResults(Map<String, SearchFacetDTO> namedFacetMap, org.apache.solr.client.solrj.response.QueryResponse response) Description copied from interface:SolrSearchServiceExtensionHandlerAttaches any additional facet results to the namedFacetMap if they exist. This should only attach facets if they do not already have result DTOs- Specified by:
setFacetResultsin interfaceSolrSearchServiceExtensionHandler- Returns:
- the result of the handler
-
buildActiveFacetFilter
@Deprecated public org.broadleafcommerce.common.extension.ExtensionResultStatusType buildActiveFacetFilter(FieldEntity entityType, String solrKey, String[] selectedValues, List<String> valueStrings) Deprecated.Description copied from interface:SolrSearchServiceExtensionHandlerBuilds the active facet filter query string for the given entity type and values. Typically this is only used when you are doing faceting on nested child documents.- Specified by:
buildActiveFacetFilterin interfaceSolrSearchServiceExtensionHandler- Returns:
-
buildActiveFacetFilter
public org.broadleafcommerce.common.extension.ExtensionResultStatusType buildActiveFacetFilter(SearchFacet facet, String[] selectedValues, List<String> valueStrings) Description copied from interface:SolrSearchServiceExtensionHandlerBuilds the active facet filter query string for the given entity type and values. Typically this is only used when you are doing faceting on nested child documents.- Specified by:
buildActiveFacetFilterin interfaceSolrSearchServiceExtensionHandler- Returns:
-
addAdditionalCategoryIds
public org.broadleafcommerce.common.extension.ExtensionResultStatusType addAdditionalCategoryIds(Category category, SearchCriteria searchCriteria, List<Long> categoryIds) Description copied from interface:SolrSearchServiceExtensionHandlerAdds any additional category ids to filter by when category browsing or searching.- Specified by:
addAdditionalCategoryIdsin interfaceSolrSearchServiceExtensionHandler- Parameters:
category- the current Category we are browsing or searching onsearchCriteria- the criteria for the current querycategoryIds- the category IDs we are going to filter on (this already includes the current category's ID)- Returns:
- NOT_HANDLED if no IDs were added, and HANDLED_CONTINUE if there were
-
getCategorySearchFacets
public org.broadleafcommerce.common.extension.ExtensionResultStatusType getCategorySearchFacets(Category category, List<SearchFacet> searchFacets) Description copied from interface:SolrSearchServiceExtensionHandlerPopulates the List of SearchFacet's for the given Category, or else returns NOT_HANDLED- Specified by:
getCategorySearchFacetsin interfaceSolrSearchServiceExtensionHandler- Returns:
-
getSearchableIndexFields
public org.broadleafcommerce.common.extension.ExtensionResultStatusType getSearchableIndexFields(List<IndexField> fields) Description copied from interface:SolrSearchServiceExtensionHandlerPopulated the List of searchable IndexField's that will be used in building the query fields (qf) for a Solr query. It is assumed that if the result of this call is NOT_HANDLED, then SolrSearchService will follow it's default behavior for populating IndexFields.- Specified by:
getSearchableIndexFieldsin interfaceSolrSearchServiceExtensionHandler- Parameters:
fields- the List to be populated.- Returns:
- HANDLED_CONTINUE if it added field, NOT_HANDLED otherwise
-
getCategoryId
public org.broadleafcommerce.common.extension.ExtensionResultStatusType getCategoryId(Category category, Long[] returnContainer) Description copied from interface:SolrSearchServiceExtensionHandlerIn certain scenarios, the requested category id might not be the one that should be used in Solr. If this method returnsExtensionResultStatusType.HANDLED, the value placed in the 0th element in the returnContainer should be used.- Specified by:
getCategoryIdin interfaceSolrSearchServiceExtensionHandler- Returns:
- the extension result status type
-
batchFetchCatalogData
public org.broadleafcommerce.common.extension.ExtensionResultStatusType batchFetchCatalogData(List<Product> products) Description copied from interface:SolrSearchServiceExtensionHandlerBatch fetch important collections for the entire list of products in single batch fetch queries. In general, this is intended to be used for search results and category landing page results. For batch fetching during solr indexing, see#startBatchEvent(List).- Specified by:
batchFetchCatalogDatain interfaceSolrSearchServiceExtensionHandler- Returns:
-
attachSortField
public org.broadleafcommerce.common.extension.ExtensionResultStatusType attachSortField(org.apache.solr.client.solrj.SolrQuery solrQuery, String requestedSortFieldName, org.apache.solr.client.solrj.SolrQuery.ORDER order) Description copied from interface:SolrSearchServiceExtensionHandlerAttaches the sort field, if able, to the givenSolrQuery.- Specified by:
attachSortFieldin interfaceSolrSearchServiceExtensionHandler- Returns:
-
getPropertyNameForIndexField
public org.broadleafcommerce.common.extension.ExtensionResultStatusType getPropertyNameForIndexField(IndexField field, FieldType fieldType, String prefix, org.broadleafcommerce.common.extension.ExtensionResultHolder<String> erh) Description copied from interface:SolrSearchServiceExtensionHandlerExtension point to allow overriding the way the property name for an index field with the given field type and prefix is built.- Specified by:
getPropertyNameForIndexFieldin interfaceSolrSearchServiceExtensionHandler- Returns:
-
attachFacet(SolrQuery, String, SearchFacetDTO, SearchCriteria)