Class DefaultSolrQueryBuilder

  • All Implemented Interfaces:
    com.broadleafcommerce.search.core.service.QueryBuilder<org.apache.solr.client.solrj.SolrQuery>

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

      Fields 
      Modifier and Type Field Description
      protected static com.broadleafcommerce.search.core.service.SearchRequestProperties DEFAULT_PROPS  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void attachEDisMax​(org.apache.solr.client.solrj.SolrQuery solrQuery)
      Configure eDisMax Query Fields to enable text search on all searchable fields
      protected void attachPage​(org.apache.solr.client.solrj.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.SolrQuery solrQuery, String query)
      Sanitizes and sets the query field on the SolrQuery
      org.apache.solr.client.solrj.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.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 defaultQueryIfEmpty​(String query)
      Returns either the provided query, or the default query if blank.
      protected void executeQueryContributors​(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)
      Executes any defined query contributors to customize the query.
      protected List<SolrQueryContributor> getContributorsForIndexableType​(com.broadleafcommerce.search.api.type.IndexableType indexableType)  
      protected List<SolrQueryContributor> getDefaultContributors()  
      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.
      protected com.broadleafcommerce.search.core.service.locale.LocaleHelper getLocaleHelper()  
    • Field Detail

      • DEFAULT_PROPS

        protected static final com.broadleafcommerce.search.core.service.SearchRequestProperties DEFAULT_PROPS
    • Constructor Detail

      • DefaultSolrQueryBuilder

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

      • constructQuery

        public org.apache.solr.client.solrj.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.SolrQuery>
        Throws:
        com.broadleafcommerce.search.api.SearchException
      • constructQuery

        public org.apache.solr.client.solrj.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.SolrQuery>
      • attachPage

        protected void attachPage​(org.apache.solr.client.solrj.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.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.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.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()
      • 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.