Interface SolrSearchServiceExtensionHandler
- All Superinterfaces:
ExtensionHandler
- All Known Implementing Classes:
AbstractSolrSearchServiceExtensionHandler,I18nSolrSearchServiceExtensionHandler
- Author:
- Andre Azzolini (apazzolini), bpolster
-
Method Summary
Modifier and TypeMethodDescriptionaddAdditionalCategoryIds(Category category, SearchCriteria searchCriteria, List<Long> categoryIds) Adds any additional category ids to filter by when category browsing or searching.attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto) Deprecated.attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto, SearchCriteria searchCriteria) Attaches the given dto to the given query, if possibleattachSortField(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.batchFetchCatalogData(List<Product> products) Batch fetch important collections for the entire list of products in single batch fetch queries.buildActiveFacetFilter(FieldEntity entityType, String solrKey, String[] selectedValues, List<String> valueStrings) Deprecated.buildActiveFacetFilter(SearchFacet facet, String[] selectedValues, List<String> valueStrings) Builds the active facet filter query string for the given entity type and values.buildPrefixListForIndexField(IndexField field, FieldType fieldType, List<String> prefixList) Returns a prefix if required for the passed in searchable field.filterSearchFacetRanges(SearchFacetDTO dto, List<SearchFacetRange> ranges) Builds the search facet ranges for the provided dto.getCategoryId(Category category, Long[] returnContainer) In certain scenarios, the requested category id might not be the one that should be used in Solr.getCategorySearchFacets(Category category, List<SearchFacet> searchFacets) Populates the List of SearchFacet's for the given Category, or else returns NOT_HANDLEDgetPropertyNameForIndexField(IndexField field, FieldType fieldType, String prefix, 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.getQueryField(org.apache.solr.client.solrj.SolrQuery query, SearchCriteria searchCriteria, IndexFieldType indexFieldType, ExtensionResultHolder<List<String>> queryFieldsResult) Finds and adds the query fields for the given search field and searchable field type.getSearchableIndexFields(List<IndexField> fields) Populated the List of searchable IndexField's that will be used in building the query fields (qf) for a Solr query.getSearchFacets(List<SearchFacet> searchFacets) Populates the List of SearchFacet's, or else returns NOT_HANDLEDmodifySearchResults(List<org.apache.solr.common.SolrDocument> responseDocuments, List<Product> products) Modifies the product search results from a Solr querymodifySolrQuery(org.apache.solr.client.solrj.SolrQuery query, String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) Provides an extension point to modify the SolrQuery.modifySolrQuery(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.setFacetResults(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 interface org.broadleafcommerce.common.extension.ExtensionHandler
getPriority, isEnabled
-
Method Details
-
buildPrefixListForIndexField
ExtensionResultStatusType buildPrefixListForIndexField(IndexField field, FieldType fieldType, List<String> prefixList) Returns a prefix if required for the passed in searchable field. -
filterSearchFacetRanges
ExtensionResultStatusType filterSearchFacetRanges(SearchFacetDTO dto, List<SearchFacetRange> ranges) Builds the search facet ranges for the provided dto.- Parameters:
dto-ranges-
-
modifySolrQuery
ExtensionResultStatusType modifySolrQuery(org.apache.solr.client.solrj.SolrQuery query, String qualifiedSolrQuery, List<SearchFacetDTO> facets, SearchCriteria searchCriteria, String defaultSort) Provides an extension point to modify the SolrQuery.- Parameters:
query-qualifiedSolrQuery-facets-searchCriteria-defaultSort-
-
modifySolrQuery
ExtensionResultStatusType modifySolrQuery(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.- Parameters:
context-query-qualifiedSolrQuery-facets-searchCriteria-defaultSort-
-
getCategoryId
In 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.- Parameters:
category-returnContainer-- Returns:
- the extension result status type
-
getQueryField
ExtensionResultStatusType getQueryField(org.apache.solr.client.solrj.SolrQuery query, SearchCriteria searchCriteria, IndexFieldType indexFieldType, ExtensionResultHolder<List<String>> queryFieldsResult) Finds 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.- Parameters:
query-searchCriteria-indexFieldType- 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
ExtensionResultStatusType modifySearchResults(List<org.apache.solr.common.SolrDocument> responseDocuments, List<Product> products) Modifies 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.
- 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
Populates the List of SearchFacet's, or else returns NOT_HANDLED- Parameters:
searchFacets- the List to populate- Returns:
- the result of the handler
-
attachFacet
@Deprecated ExtensionResultStatusType attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto) Deprecated.Attaches the given dto to the given query, if possible- Parameters:
query- the SolrQuery to attach the facet todto-- Returns:
- the result of the handler
-
attachFacet
ExtensionResultStatusType attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto, SearchCriteria searchCriteria) Attaches the given dto to the given query, if possible- Parameters:
query- the SolrQuery to attach the facet todto-searchCriteria-- Returns:
- the result of the handler
-
setFacetResults
ExtensionResultStatusType setFacetResults(Map<String, SearchFacetDTO> namedFacetMap, org.apache.solr.client.solrj.response.QueryResponse response) Attaches any additional facet results to the namedFacetMap if they exist. This should only attach facets if they do not already have result DTOs- Parameters:
namedFacetMap-response-- Returns:
- the result of the handler
-
buildActiveFacetFilter
ExtensionResultStatusType buildActiveFacetFilter(FieldEntity entityType, String solrKey, String[] selectedValues, List<String> valueStrings) Deprecated.Builds 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.- Parameters:
entityType-solrKey-selectedValues-valueStrings-- Returns:
-
buildActiveFacetFilter
ExtensionResultStatusType buildActiveFacetFilter(SearchFacet facet, String[] selectedValues, List<String> valueStrings) Builds 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.- Parameters:
facet-selectedValues-valueStrings-- Returns:
-
addAdditionalCategoryIds
ExtensionResultStatusType addAdditionalCategoryIds(Category category, SearchCriteria searchCriteria, List<Long> categoryIds) Adds any additional category ids to filter by when category browsing or searching.- 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
ExtensionResultStatusType getCategorySearchFacets(Category category, List<SearchFacet> searchFacets) Populates the List of SearchFacet's for the given Category, or else returns NOT_HANDLED- Parameters:
category-searchFacets-- Returns:
-
getSearchableIndexFields
Populated 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.- Parameters:
fields- the List to be populated.- Returns:
- HANDLED_CONTINUE if it added field, NOT_HANDLED otherwise
-
batchFetchCatalogData
Batch 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).- Parameters:
products-- Returns:
-
attachSortField
ExtensionResultStatusType attachSortField(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.- Parameters:
solrQuery-requestedSortFieldName-order-- Returns:
-
getPropertyNameForIndexField
ExtensionResultStatusType getPropertyNameForIndexField(IndexField field, FieldType fieldType, String prefix, 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.- Parameters:
field-fieldType-prefix-erh-- Returns:
-
attachFacet(SolrQuery, String, SearchFacetDTO, SearchCriteria)