QueryComponentFactory
in package
Uses
QueryComponentFilterTrait, QueryComponentBoostTrait, QueryComponentFacetTrait
Class QueryComponentFactory
Build a query component for each available build part
Table of Contents
Constants
- DEFAULT_FIELDS = [\Firesphere\SolrSearch\Services\SolrCoreService::ID_FIELD, \Firesphere\SolrSearch\Services\SolrCoreService::CLASS_ID_FIELD, \Firesphere\SolrSearch\Services\SolrCoreService::CLASSNAME]
- Default fields that should always be added
Properties
- $boostTerms : array<string|int, mixed>
- Terms that are going to be boosted
- $builds : array<string|int, mixed>
- $clientQuery : Query
- $helper : Helper
- $index : BaseIndex
- $query : BaseQuery
- $queryArray : array<string|int, mixed>
Methods
- buildQuery() : Query
- Build the full query
- escapeSearch() : string
- Escape the search query
- getBoostTerms() : array<string|int, mixed>
- Get the boosted terms
- getClientQuery() : Query
- Get the client Query components
- getHelper() : Helper
- Get the query helper
- getIndex() : BaseIndex
- Get the BaseIndex
- getQuery() : BaseQuery
- Get the base query
- getQueryArray() : array<string|int, mixed>
- Get the array of terms used to query Solr
- setBoostTerms() : QueryComponentFactory
- Set the boosted terms manually
- setClientQuery() : self
- Set a custom Client Query object
- setHelper() : self
- Set the Helper
- setIndex() : self
- Set a BaseIndex
- setQuery() : self
- Set the base query
- setQueryArray() : self
- Set the array of queries that are sent to Solr
- buildAndFacetFilterQuery() : mixed
- Add AND facet filters based on the current request
- buildBoosts() : void
- Build the boosted field setup through Criteria
- buildClassFilter() : void
- Add filtered queries based on class hierarchy We only need the class itself, since the hierarchy will take care of the rest
- buildCriteriaFilter() : Criteria
- Convert a field/value filter pair to a Criteria object that can build part of a Solr query.
- buildExcludes() : void
- Remove items to exclude
- buildFilters() : void
- Create filter queries
- buildOrFacetFilterQuery() : mixed
- Add OR facet filters based on the current request
- buildQueryBoost() : array<string|int, mixed>
- Set boosting at Query time
- buildQueryFacets() : void
- Add facets from the index, to make sure Solr returns the expected facets and their respective count on the correct fields
- buildSpellcheck() : void
- Add spellcheck elements
- buildTerms() : void
- Build the terms and boost terms
- buildViewFilter() : void
- Add filtering on canView
- createFacetCriteria() : mixed
- Combine all facets as AND facet filters for the results
- getBuildTerm() : string
- Get the escaped search string, or, if empty, a global search
- getFieldFacets() : array<string|int, mixed>
- Get the field and it's respected values to filter on to generate Criteria from
- isFuzzy() : string
- If the search is fuzzy, add fuzzyness
Constants
DEFAULT_FIELDS
Default fields that should always be added
public
array<string|int, mixed>
DEFAULT_FIELDS
= [\Firesphere\SolrSearch\Services\SolrCoreService::ID_FIELD, \Firesphere\SolrSearch\Services\SolrCoreService::CLASS_ID_FIELD, \Firesphere\SolrSearch\Services\SolrCoreService::CLASSNAME]
Properties
$boostTerms
Terms that are going to be boosted
protected
array<string|int, mixed>
$boostTerms
= []
$builds
protected
static array<string|int, mixed>
$builds
= ['Terms', 'ViewFilter', 'ClassFilter', 'Filters', 'Excludes', 'QueryFacets', 'AndFacetFilterQuery', 'OrFacetFilterQuery', 'Spellcheck']
Build methods to run
$clientQuery
protected
Query
$clientQuery
Solarium query
$helper
protected
Helper
$helper
Helper to escape the query terms properly
$index
protected
BaseIndex
$index
Index to query
$query
protected
BaseQuery
$query
BaseQuery that needs to be executed
$queryArray
protected
array<string|int, mixed>
$queryArray
= []
Resulting query parts as an array
Methods
buildQuery()
Build the full query
public
buildQuery() : Query
Return values
QueryescapeSearch()
Escape the search query
public
escapeSearch(string $searchTerm) : string
Parameters
- $searchTerm : string
Return values
stringgetBoostTerms()
Get the boosted terms
public
getBoostTerms() : array<string|int, mixed>
Return values
array<string|int, mixed>getClientQuery()
Get the client Query components
public
getClientQuery() : Query
Return values
QuerygetHelper()
Get the query helper
public
getHelper() : Helper
Return values
HelpergetIndex()
Get the BaseIndex
public
getIndex() : BaseIndex
Return values
BaseIndexgetQuery()
Get the base query
public
getQuery() : BaseQuery
Return values
BaseQuerygetQueryArray()
Get the array of terms used to query Solr
public
getQueryArray() : array<string|int, mixed>
Return values
array<string|int, mixed>setBoostTerms()
Set the boosted terms manually
public
setBoostTerms(array<string|int, mixed> $boostTerms) : QueryComponentFactory
Parameters
- $boostTerms : array<string|int, mixed>
Return values
QueryComponentFactorysetClientQuery()
Set a custom Client Query object
public
setClientQuery(Query $clientQuery) : self
Parameters
- $clientQuery : Query
Return values
selfsetHelper()
Set the Helper
public
setHelper(Helper $helper) : self
Parameters
- $helper : Helper
Return values
selfsetIndex()
Set a BaseIndex
public
setIndex(BaseIndex $index) : self
Parameters
- $index : BaseIndex
Return values
selfsetQuery()
Set the base query
public
setQuery(BaseQuery $query) : self
Parameters
- $query : BaseQuery
Return values
selfsetQueryArray()
Set the array of queries that are sent to Solr
public
setQueryArray(array<string|int, mixed> $queryArray) : self
Parameters
- $queryArray : array<string|int, mixed>
Return values
selfbuildAndFacetFilterQuery()
Add AND facet filters based on the current request
protected
buildAndFacetFilterQuery() : mixed
buildBoosts()
Build the boosted field setup through Criteria
protected
buildBoosts() : void
Add the index-time boosting to the query
buildClassFilter()
Add filtered queries based on class hierarchy We only need the class itself, since the hierarchy will take care of the rest
protected
buildClassFilter() : void
buildCriteriaFilter()
Convert a field/value filter pair to a Criteria object that can build part of a Solr query.
protected
buildCriteriaFilter(string $field, mixed $value) : Criteria
If a Criteria object is passed as the value, it will be returned unmodified.
Parameters
- $field : string
- $value : mixed
Return values
CriteriabuildExcludes()
Remove items to exclude
protected
buildExcludes() : void
buildFilters()
Create filter queries
protected
buildFilters() : void
buildOrFacetFilterQuery()
Add OR facet filters based on the current request
protected
buildOrFacetFilterQuery() : mixed
buildQueryBoost()
Set boosting at Query time
protected
buildQueryBoost(array<string|int, mixed> $search, string $term, array<string|int, mixed> &$boostTerms) : array<string|int, mixed>
Parameters
- $search : array<string|int, mixed>
- $term : string
- $boostTerms : array<string|int, mixed>
Return values
array<string|int, mixed>buildQueryFacets()
Add facets from the index, to make sure Solr returns the expected facets and their respective count on the correct fields
protected
buildQueryFacets() : void
buildSpellcheck()
Add spellcheck elements
protected
buildSpellcheck() : void
buildTerms()
Build the terms and boost terms
protected
buildTerms() : void
buildViewFilter()
Add filtering on canView
protected
buildViewFilter() : void
createFacetCriteria()
Combine all facets as AND facet filters for the results
protected
createFacetCriteria(null|Criteria &$criteria, string $field, array<string|int, mixed> $filter) : mixed
Parameters
- $criteria : null|Criteria
- $field : string
- $filter : array<string|int, mixed>
getBuildTerm()
Get the escaped search string, or, if empty, a global search
protected
getBuildTerm(array<string|int, mixed> $search) : string
Parameters
- $search : array<string|int, mixed>
Return values
stringgetFieldFacets()
Get the field and it's respected values to filter on to generate Criteria from
protected
getFieldFacets(array<string|int, mixed> $filterFacets, array<string|int, mixed> $config) : array<string|int, mixed>
Parameters
- $filterFacets : array<string|int, mixed>
- $config : array<string|int, mixed>
Return values
array<string|int, mixed>isFuzzy()
If the search is fuzzy, add fuzzyness
protected
isFuzzy( $search) : string