Class DefaultSolrFilterContributor

    • Field Summary

      • Fields inherited from interface org.springframework.core.Ordered

        HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultSolrFilterContributor​(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void attachFilters​(org.apache.solr.client.solrj.SolrQuery solrQuery, List<com.broadleafcommerce.search.api.domain.Filter> filters, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, String locale)
      Configure query for Solr with necessary filters
      protected String buildFilterQuery​(@NonNull com.broadleafcommerce.search.api.domain.Filter searchFilter, String fieldName, @NonNull com.broadleafcommerce.search.api.domain.FieldDefinition fieldDefinition)
      Create the filter query described by the searchFilter for the given field.
      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)
      Customize the provided solrQuery with some additional behavior.
      boolean contributeOnTypeAhead()  
      protected void decodeFilterValues​(com.broadleafcommerce.search.api.domain.Filter filter)
      Decodes the given Filter.getValues().
      protected Optional<String> getFilterQuery​(com.broadleafcommerce.search.api.domain.Filter filter, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fields, String locale)
      Build the filter query to attach to the Solr query, if it matches an existing field.
      protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()  
      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)
      Determines if this contributor should run.
    • Constructor Detail

      • DefaultSolrFilterContributor

        public DefaultSolrFilterContributor​(com.broadleafcommerce.search.provider.solr.SolrFieldService solrFieldService)
    • Method Detail

      • 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,
                                          @Nullable
                                          com.broadleafcommerce.search.core.service.SearchRequestProperties properties,
                                          @Nullable
                                          String locale,
                                          @Nullable
                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from class: AbstractSolrQueryContributor
        Customize the provided solrQuery with some additional behavior.
        Specified by:
        contributeInternal in class AbstractSolrQueryContributor
        Parameters:
        solrQuery - The query to customize
        searchRequest - The search query request
        fieldDefinitions - The fields to perform the search on
        page - Page information for page to retrieve for query
        properties - Additional properties for this query
        locale - The locale of this search
        context - The context information surrounding sandboxing/multitenant state
      • attachFilters

        protected void attachFilters​(org.apache.solr.client.solrj.SolrQuery solrQuery,
                                     @Nullable
                                     List<com.broadleafcommerce.search.api.domain.Filter> filters,
                                     List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions,
                                     @Nullable
                                     String locale)
        Configure query for Solr with necessary filters
        Parameters:
        solrQuery - Query to attach filters onto
        filters - The filters to apply to the query
        fieldDefinitions - All field definitions for the type being queried
        locale - (optional) the locale of the query
      • decodeFilterValues

        protected void decodeFilterValues​(com.broadleafcommerce.search.api.domain.Filter filter)
        Decodes the given Filter.getValues().
        Parameters:
        filter - the Filter to decode
      • getFilterQuery

        protected Optional<String> getFilterQuery​(com.broadleafcommerce.search.api.domain.Filter filter,
                                                  List<com.broadleafcommerce.search.api.domain.FieldDefinition> fields,
                                                  @Nullable
                                                  String locale)
        Build the filter query to attach to the Solr query, if it matches an existing field.
        Parameters:
        filter - the filter to convert to a Solr filter
        fields - All field definitions for the type being queried
        locale - (optional) the locale of the query
        Returns:
        if present, the filter query to attach to the Solr query
      • buildFilterQuery

        protected String buildFilterQuery​(@NonNull
                                          @NonNull com.broadleafcommerce.search.api.domain.Filter searchFilter,
                                          String fieldName,
                                          @NonNull
                                          @NonNull com.broadleafcommerce.search.api.domain.FieldDefinition fieldDefinition)
        Create the filter query described by the searchFilter for the given field. A tag will be generated for the searchFilter name and prepended to the filter query to enable excluding it for the purpose of generating accurate Facet count results.
        Parameters:
        searchFilter - The search filter to build as a Solr query
        fieldName - The typed Solr name of the field on which to filter
        fieldDefinition - The FieldDefinition matching the Filter by name
        Returns:
        Tagged Solr filter query
      • shouldContribute

        protected boolean shouldContribute​(org.apache.solr.client.solrj.SolrQuery solrQuery,
                                           com.broadleafcommerce.search.api.domain.SearchRequest searchRequest,
                                           org.springframework.data.domain.Pageable page,
                                           @Nullable
                                           com.broadleafcommerce.search.core.service.SearchRequestProperties properties,
                                           @Nullable
                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from class: AbstractSolrQueryContributor
        Determines if this contributor should run.
        Specified by:
        shouldContribute in class AbstractSolrQueryContributor
        Parameters:
        solrQuery - The query to customize
        searchRequest - The search query request
        page - Page information for page to retrieve for query
        properties - Additional properties for this query.
        context - The context information surrounding sandboxing/multitenant state
        Returns:
        whether this contributor should run
      • contributeOnTypeAhead

        public boolean contributeOnTypeAhead()
        Returns:
        Should this contributor be executed on TypeAhead requests?
      • getSolrFieldService

        protected com.broadleafcommerce.search.provider.solr.SolrFieldService getSolrFieldService()