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.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.SearchRequestPropertiesDEFAULT_PROPS
-
Constructor Summary
Constructors Constructor Description DefaultSolrQueryBuilder(com.broadleafcommerce.search.core.service.locale.LocaleHelper localeHelper, List<SolrQueryContributor> contributors)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidattachEDisMax(org.apache.solr.client.solrj.SolrQuery solrQuery)Configure eDisMax Query Fields to enable text search on all searchable fieldsprotected voidattachPage(org.apache.solr.client.solrj.SolrQuery solrQuery, org.springframework.data.domain.Pageable page)Configure query to Solr for retrieving requested page of resultsprotected voidattachQuery(org.apache.solr.client.solrj.SolrQuery solrQuery, String query)Sanitizes and sets the query field on theSolrQueryorg.apache.solr.client.solrj.SolrQueryconstructQuery(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.SolrQueryconstructQuery(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 StringdefaultQueryIfEmpty(String query)Returns either the provided query, or thedefault queryif blank.protected voidexecuteQueryContributors(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 specificIndexableTypevia anIndexableTypeSolrQueryContributor, then the contributors listed here will be used instead ofdefaultContributors.protected com.broadleafcommerce.search.core.service.locale.LocaleHelpergetLocaleHelper()
-
-
-
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:
constructQueryin interfacecom.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:
constructQueryin interfacecom.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 informationpage- 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 theSolrQuery- Parameters:
solrQuery- Query to execute in Solrquery- 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 customizesearchRequest- The search query requestpage- Page information for page to retrieve for querylocale- (optional) the locale of the queryfieldDefinitions- The fields to perform the search oncontext- 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 thedefault queryif 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 specificIndexableTypevia anIndexableTypeSolrQueryContributor, then the contributors listed here will be used instead ofdefaultContributors.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.
-
-