Class DefaultSolrQueryBuilder

java.lang.Object
com.broadleafcommerce.search.provider.solr.DefaultSolrQueryBuilder
All Implemented Interfaces:
com.broadleafcommerce.search.core.service.QueryBuilder<org.apache.solr.client.solrj.request.SolrQuery>

public class DefaultSolrQueryBuilder extends Object implements com.broadleafcommerce.search.core.service.QueryBuilder<org.apache.solr.client.solrj.request.SolrQuery>
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultSolrQueryBuilder(com.broadleafcommerce.search.core.service.locale.LocaleHelper localeHelper, List<SolrQueryContributor> contributors)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    attachEDisMax(org.apache.solr.client.solrj.request.SolrQuery solrQuery)
    Configure eDisMax Query Fields to enable text search on all searchable fields
    protected void
    attachPage(org.apache.solr.client.solrj.request.SolrQuery solrQuery, org.springframework.data.domain.Pageable page)
    Configure query to Solr for retrieving requested page of results
    protected void
    attachQuery(org.apache.solr.client.solrj.request.SolrQuery solrQuery, String query)
    Sanitizes and sets the query field on the SolrQuery
    org.apache.solr.client.solrj.request.SolrQuery
    constructQuery(com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    org.apache.solr.client.solrj.request.SolrQuery
    constructQuery(com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
     
    protected String
    Returns either the provided query, or the default query if blank.
    protected void
    executeQueryContributors(org.apache.solr.client.solrj.request.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)
    Executes any defined query contributors to customize the query.
    getContributorsForIndexableType(com.broadleafcommerce.search.api.type.IndexableType indexableType)
     
     
    protected Map<com.broadleafcommerce.search.api.type.IndexableType,List<SolrQueryContributor>>
    If any contributors have been defined for a specific IndexableType via an IndexableTypeSolrQueryContributor, then the contributors listed here will be used instead of defaultContributors.
    protected com.broadleafcommerce.search.core.service.locale.LocaleHelper
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DefaultSolrQueryBuilder

      public DefaultSolrQueryBuilder(com.broadleafcommerce.search.core.service.locale.LocaleHelper localeHelper, List<SolrQueryContributor> contributors)
  • Method Details

    • constructQuery

      public org.apache.solr.client.solrj.request.SolrQuery constructQuery(com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) throws com.broadleafcommerce.search.api.SearchException
      Specified by:
      constructQuery in interface com.broadleafcommerce.search.core.service.QueryBuilder<org.apache.solr.client.solrj.request.SolrQuery>
      Throws:
      com.broadleafcommerce.search.api.SearchException
    • constructQuery

      public org.apache.solr.client.solrj.request.SolrQuery constructQuery(com.broadleafcommerce.search.api.domain.SearchRequest searchRequest, org.springframework.data.domain.Pageable page, List<com.broadleafcommerce.search.api.domain.FieldDefinition> fieldDefinitions, com.broadleafcommerce.search.core.service.SearchRequestProperties properties, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      constructQuery in interface com.broadleafcommerce.search.core.service.QueryBuilder<org.apache.solr.client.solrj.request.SolrQuery>
    • attachPage

      protected void attachPage(org.apache.solr.client.solrj.request.SolrQuery solrQuery, org.springframework.data.domain.Pageable page)
      Configure query to Solr for retrieving requested page of results
      Parameters:
      solrQuery - Query to configure paging information
      page - Requested page of results
    • attachQuery

      protected void attachQuery(org.apache.solr.client.solrj.request.SolrQuery solrQuery, @Nullable String query)
      Sanitizes and sets the query field on the SolrQuery
      Parameters:
      solrQuery - Query to execute in Solr
      query - The raw query string
    • attachEDisMax

      protected void attachEDisMax(org.apache.solr.client.solrj.request.SolrQuery solrQuery)
      Configure eDisMax Query Fields to enable text search on all searchable fields
      Parameters:
      solrQuery - Query to attach query field configuration
    • executeQueryContributors

      protected void executeQueryContributors(org.apache.solr.client.solrj.request.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, @Nullable String locale, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Executes any defined query contributors to customize the query.
      Parameters:
      solrQuery - The query to customize
      searchRequest - The search query request
      page - Page information for page to retrieve for query
      locale - (optional) the locale of the query
      fieldDefinitions - The fields to perform the search on
      context - The context information surrounding sandboxing/multitenant state
    • getContributorsForIndexableType

      protected List<SolrQueryContributor> getContributorsForIndexableType(com.broadleafcommerce.search.api.type.IndexableType indexableType)
    • defaultQueryIfEmpty

      protected String defaultQueryIfEmpty(@Nullable String query)
      Returns either the provided query, or the default query if blank.
      Parameters:
      query - the requested query
      Returns:
      requested query, or default query if blank
    • getLocaleHelper

      protected com.broadleafcommerce.search.core.service.locale.LocaleHelper getLocaleHelper()
    • getDefaultContributors

      protected List<SolrQueryContributor> getDefaultContributors()
    • getIndexableTypeContributors

      protected Map<com.broadleafcommerce.search.api.type.IndexableType,List<SolrQueryContributor>> getIndexableTypeContributors()
      If any contributors have been defined for a specific IndexableType via an IndexableTypeSolrQueryContributor, then the contributors listed here will be used instead of defaultContributors.

      For such an indexable type, this will contain the indexable-type-specific contributors in addition to the default contributors, excluding those which were extended by the indexable-type-specific contributors.