Interface SolrSearchServiceExtensionHandler

All Superinterfaces:
org.broadleafcommerce.common.extension.ExtensionHandler
All Known Implementing Classes:
AbstractSolrSearchServiceExtensionHandler, I18nSolrSearchServiceExtensionHandler

public interface SolrSearchServiceExtensionHandler extends org.broadleafcommerce.common.extension.ExtensionHandler
Author:
Andre Azzolini (apazzolini), bpolster
  • Method Summary

    Modifier and Type
    Method
    Description
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    addAdditionalCategoryIds(Category category, SearchCriteria searchCriteria, List<Long> categoryIds)
    Adds any additional category ids to filter by when category browsing or searching.
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto)
    org.broadleafcommerce.common.extension.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
    org.broadleafcommerce.common.extension.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 given SolrQuery.
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    Batch fetch important collections for the entire list of products in single batch fetch queries.
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    buildActiveFacetFilter(FieldEntity entityType, String solrKey, String[] selectedValues, List<String> valueStrings)
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    buildActiveFacetFilter(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.ExtensionResultStatusType
    buildPrefixListForIndexField(IndexField field, FieldType fieldType, List<String> prefixList)
    Returns a prefix if required for the passed in searchable field.
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    Builds the search facet ranges for the provided dto.
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    getCategoryId(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.ExtensionResultStatusType
    Populates the List of SearchFacet's for the given Category, or else returns NOT_HANDLED
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    getPropertyNameForIndexField(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.ExtensionResultStatusType
    getQueryField(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.ExtensionResultStatusType
    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.ExtensionResultStatusType
    Populates the List of SearchFacet's, or else returns NOT_HANDLED
    org.broadleafcommerce.common.extension.ExtensionResultStatusType
    modifySearchResults(List<org.apache.solr.common.SolrDocument> responseDocuments, List<Product> products)
    Modifies the product search results from a Solr query
    org.broadleafcommerce.common.extension.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.
    org.broadleafcommerce.common.extension.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.
    org.broadleafcommerce.common.extension.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.

    Methods inherited from interface org.broadleafcommerce.common.extension.ExtensionHandler

    getPriority, isEnabled
  • Method Details

    • buildPrefixListForIndexField

      org.broadleafcommerce.common.extension.ExtensionResultStatusType buildPrefixListForIndexField(IndexField field, FieldType fieldType, List<String> prefixList)
      Returns a prefix if required for the passed in searchable field.
    • filterSearchFacetRanges

      org.broadleafcommerce.common.extension.ExtensionResultStatusType filterSearchFacetRanges(SearchFacetDTO dto, List<SearchFacetRange> ranges)
      Builds the search facet ranges for the provided dto.
      Parameters:
      dto -
      ranges -
    • modifySolrQuery

      org.broadleafcommerce.common.extension.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

      org.broadleafcommerce.common.extension.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

      org.broadleafcommerce.common.extension.ExtensionResultStatusType getCategoryId(Category category, Long[] returnContainer)
      In certain scenarios, the requested category id might not be the one that should be used in Solr. If this method returns ExtensionResultStatusType.HANDLED, the value placed in the 0th element in the returnContainer should be used.
      Parameters:
      category -
      returnContainer -
      Returns:
      the extension result status type
    • getQueryField

      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)

      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 is ExtensionResultStatusType.NOT_HANDLED then the default behavior is to only do that.

      Parameters:
      query -
      searchCriteria -
      indexFieldType - the field type of the field
      queryFieldsResult - 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

      org.broadleafcommerce.common.extension.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 Solr
      products - the products that tie to the response documents
      Returns:
      the result of the handler, if NOT_HANDLED, then no changes where made
    • getSearchFacets

      org.broadleafcommerce.common.extension.ExtensionResultStatusType getSearchFacets(List<SearchFacet> searchFacets)
      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 org.broadleafcommerce.common.extension.ExtensionResultStatusType attachFacet(org.apache.solr.client.solrj.SolrQuery query, String indexField, SearchFacetDTO dto)
      Attaches the given dto to the given query, if possible
      Parameters:
      query - the SolrQuery to attach the facet to
      dto -
      Returns:
      the result of the handler
    • attachFacet

      org.broadleafcommerce.common.extension.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 to
      dto -
      searchCriteria -
      Returns:
      the result of the handler
    • setFacetResults

      org.broadleafcommerce.common.extension.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

      org.broadleafcommerce.common.extension.ExtensionResultStatusType buildActiveFacetFilter(FieldEntity entityType, String solrKey, 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:
      entityType -
      solrKey -
      selectedValues -
      valueStrings -
      Returns:
    • buildActiveFacetFilter

      org.broadleafcommerce.common.extension.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

      org.broadleafcommerce.common.extension.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 on
      searchCriteria - the criteria for the current query
      categoryIds - 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

      org.broadleafcommerce.common.extension.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

      org.broadleafcommerce.common.extension.ExtensionResultStatusType 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. 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

      org.broadleafcommerce.common.extension.ExtensionResultStatusType batchFetchCatalogData(List<Product> products)
      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

      org.broadleafcommerce.common.extension.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 given SolrQuery.
      Parameters:
      solrQuery -
      requestedSortFieldName -
      order -
      Returns:
    • getPropertyNameForIndexField

      org.broadleafcommerce.common.extension.ExtensionResultStatusType getPropertyNameForIndexField(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.
      Parameters:
      field -
      fieldType -
      prefix -
      erh -
      Returns: