SilverStripe solr Search

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

$builds

protected static array<string|int, mixed> $builds = ['Terms', 'ViewFilter', 'ClassFilter', 'Filters', 'Excludes', 'QueryFacets', 'AndFacetFilterQuery', 'OrFacetFilterQuery', 'Spellcheck']

Build methods to run

$queryArray

protected array<string|int, mixed> $queryArray = []

Resulting query parts as an array

Methods

escapeSearch()

Escape the search query

public escapeSearch(string $searchTerm) : string
Parameters
$searchTerm : string
Return values
string

getBoostTerms()

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
Query

getQueryArray()

Get the array of terms used to query Solr

public getQueryArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

setClientQuery()

Set a custom Client Query object

public setClientQuery(Query $clientQuery) : self
Parameters
$clientQuery : Query
Return values
self

setHelper()

Set the Helper

public setHelper(Helper $helper) : self
Parameters
$helper : Helper
Return values
self

setQueryArray()

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
self

buildAndFacetFilterQuery()

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
Criteria

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

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
string

getFieldFacets()

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
Parameters
$search :
Return values
string

        
On this page

Search results