VuFind API Documentation

QueryBuilder
in package
implements QueryBuilderInterface

SOLR QueryBuilder.

Tags
category

VuFind

author

Andrew S. Nagy vufind-tech@lists.sourceforge.net

author

David Maus maus@hab.de

author

Demian Katz demian.katz@villanova.edu

license

http://opensource.org/licenses/gpl-2.0.php GNU General Public License

link
https://vufind.org

Interfaces, Classes, Traits and Enums

QueryBuilderInterface
SOLR QueryBuilder interface definition.

Table of Contents

$createSpellingQuery  : bool
Should we create the spellcheck.q parameter when appropriate?
$defaultDismaxHandler  : string
Default dismax handler (if no DismaxHandler set in specs).
$exactSpecs  : array<string|int, mixed>
Search specs for exact searches.
$fieldsToHighlight  : string
Solr fields to highlight. Also serves as a flag for whether to perform highlight-specific behavior; if the field list is empty, highlighting is skipped.
$globalExtraParams  : array<string|int, mixed>
Global extra Solr query parameters
$luceneHelper  : LuceneSyntaxHelper
Lucene syntax helper
$specs  : array<string|int, mixed>
Search specs.
__construct()  : void
Constructor.
build()  : ParamBag
Return SOLR search parameters based on a user query and params.
getLuceneHelper()  : LuceneSyntaxHelper
Get Lucene syntax helper
setCreateSpellingQuery()  : void
Control whether or not the QueryBuilder should create a spellcheck.q parameter. (Turned off by default).
setFieldsToHighlight()  : QueryBuilder
Set list of fields to highlight, if any (or '*' for all). Set to an empty string (the default) to completely disable highlighting-related functionality.
setLuceneHelper()  : void
Set Lucene syntax helper
setSpecs()  : void
Set query builder search specs.
checkParamConditions()  : bool
Check if the conditions match for an extra parameter
createAdvancedInnerSearchString()  : string
Return advanced inner search string based on input and handler.
createSearchString()  : string
Return search string based on input and handler.
fixTrailingQuestionMarks()  : string
If the query ends in a non-escaped question mark, the user may not really intend to use the question mark as a wildcard -- let's account for that possibility.
getFieldsToHighlight()  : string
Get list of fields to highlight, filtered by array.
getNormalizedQueryString()  : string
Given a Query object, return a fully normalized version of the query string.
getSearchHandler()  : SearchHandler|null
Return named search handler.
getSearchTypes()  : array<string|int, mixed>
Get an array of search types used in the given search
hasDismaxParamsField()  : bool
Check if any of the given search types has the field in DismaxParams
reduceQueryGroup()  : Query
Reduce query group a single query.
reduceQueryGroupComponents()  : string
Reduce components of query group to a search string of a simple query.

Properties

$createSpellingQuery

Should we create the spellcheck.q parameter when appropriate?

protected bool $createSpellingQuery = false

$defaultDismaxHandler

Default dismax handler (if no DismaxHandler set in specs).

protected string $defaultDismaxHandler

$exactSpecs

Search specs for exact searches.

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

$fieldsToHighlight

Solr fields to highlight. Also serves as a flag for whether to perform highlight-specific behavior; if the field list is empty, highlighting is skipped.

protected string $fieldsToHighlight = ''

$globalExtraParams

Global extra Solr query parameters

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

$specs

Search specs.

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

Methods

__construct()

Constructor.

public __construct([array<string|int, mixed> $specs = [] ][, string $defaultDismaxHandler = 'dismax' ]) : void
Parameters
$specs : array<string|int, mixed> = []

Search handler specifications

$defaultDismaxHandler : string = 'dismax'

Default dismax handler (if no DismaxHandler set in specs).

Return values
void

setCreateSpellingQuery()

Control whether or not the QueryBuilder should create a spellcheck.q parameter. (Turned off by default).

public setCreateSpellingQuery(bool $enable) : void
Parameters
$enable : bool

Should spelling query generation be enabled?

Return values
void

setFieldsToHighlight()

Set list of fields to highlight, if any (or '*' for all). Set to an empty string (the default) to completely disable highlighting-related functionality.

public setFieldsToHighlight(string $list) : QueryBuilder
Parameters
$list : string

Highlighting field list

Return values
QueryBuilder

setSpecs()

Set query builder search specs.

public setSpecs(array<string|int, mixed> $specs) : void
Parameters
$specs : array<string|int, mixed>

Search specs

Return values
void

checkParamConditions()

Check if the conditions match for an extra parameter

protected checkParamConditions(AbstractQuery $query, ParamBag|null $params, array<string|int, mixed> $conditions) : bool
Parameters
$query : AbstractQuery

Search query

$params : ParamBag|null

Search backend parameters

$conditions : array<string|int, mixed>

Required conditions

Return values
bool

createAdvancedInnerSearchString()

Return advanced inner search string based on input and handler.

protected createAdvancedInnerSearchString(string $string, SearchHandler $handler) : string
Parameters
$string : string

Input search string

$handler : SearchHandler

Search handler

Return values
string

createSearchString()

Return search string based on input and handler.

protected createSearchString(string $string[, SearchHandler $handler = null ]) : string
Parameters
$string : string

Input search string

$handler : SearchHandler = null

Search handler

Return values
string

fixTrailingQuestionMarks()

If the query ends in a non-escaped question mark, the user may not really intend to use the question mark as a wildcard -- let's account for that possibility.

protected fixTrailingQuestionMarks(string $string) : string
Parameters
$string : string

Search query to adjust

Return values
string

getFieldsToHighlight()

Get list of fields to highlight, filtered by array.

protected getFieldsToHighlight([array<string|int, mixed> $filter = [] ]) : string
Parameters
$filter : array<string|int, mixed> = []

Field list to use as a filter.

Return values
string

getNormalizedQueryString()

Given a Query object, return a fully normalized version of the query string.

protected getNormalizedQueryString(Query $query) : string
Parameters
$query : Query

Query object

Return values
string

getSearchHandler()

Return named search handler.

protected getSearchHandler(string $handler, string $searchString) : SearchHandler|null
Parameters
$handler : string

Search handler name

$searchString : string

Search query

Return values
SearchHandler|null

getSearchTypes()

Get an array of search types used in the given search

protected getSearchTypes(AbstractQuery $query) : array<string|int, mixed>
Parameters
$query : AbstractQuery

Query

Return values
array<string|int, mixed>

hasDismaxParamsField()

Check if any of the given search types has the field in DismaxParams

protected hasDismaxParamsField(array<string|int, mixed> $searchTypes, string $field) : bool
Parameters
$searchTypes : array<string|int, mixed>

Search types to check

$field : string

Field to check for

Return values
bool

reduceQueryGroupComponents()

Reduce components of query group to a search string of a simple query.

protected reduceQueryGroupComponents(AbstractQuery $component) : string

This function implements the recursive reduction of a query group.

Parameters
$component : AbstractQuery

Component

Tags
see
QueryBuilder::reduceQueryGroup()
Return values
string

Search results