SearchConfig
in package
Stores the repository search configuration, e.g. full text search options and pagination options.
Tags
Table of Contents
Constants
- FTS_BINARY = 'BINARY'
Properties
- $class : string|null
- An optional class of the for the objects returned as the search results (to be used by extension libraries).
- $count : int|null
- Total number of resources matching the search (despite limit/offset)
- $ftsFragmentDelimiter : string|array<string|int, string>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsHighlightAll : bool|array<string|int, bool>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsMaxFragments : int|array<string|int, int>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsMaxWords : int|array<string|int, int>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsMinWords : int|array<string|int, int>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsProperty : array<string|int, string|array<string|int, string>>
- Limits highlighting to indicated properties.
- $ftsQuery : string|array<string|int, string>
- A full text search query used for search results highlighting.
- $ftsShortWord : int|array<string|int, int>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsStartSel : string|array<string|int, string>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $ftsStopSel : string|array<string|int, string>
- Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
- $limit : int|null
- Maximum number of returned resources (only resources matched by the search are counted - see `$metadataMode`).
- $metadataMode : string|null
- Controls amount of metadata included in the search results.
- $metadataParentProperty : string|null
- RDF predicate used by some of metadataModes.
- $offset : int|null
- Offset of the first returned result.
- $orderBy : array<string|int, string>
- List of metadata properties to order results by.
- $orderByCollation : string|null
- If specified, determines the collation used for ordering the search results.
- $orderByLang : string|null
- If specified, only property values with a given language are taken into account for ordering search matches.
- $relativesProperties : array<string|int, string>
- List of metadata properties to fetch for relative-according-to-metadata-read-mode resources.
- $resourceProperties : array<string|int, string>
- List of metadata properties to fetch for the resource.
- $skipArtificialProperties : bool
- Should artificially generated search properties denoting search match, ordering, FTS highlighting, etc. be skipped or included.
- $highlightParam : array<string|int, string>
Methods
- factory() : SearchConfig
- Creates an instance of the SearchConfig class from the POST data or given array.
- getHeaders() : array<string|int, string>
- Returns HTTP request headers setting metadata read mode and metadata parent property according to the search config settings.
- getSanitizedCopy() : self
- Returns an object with all fts properties being arrays of the same count as the $ftsQuery property. Also, all $ftsProperty value is assured to be an array.
- getTsHeadlineOptions() : string
- readFtsConfigFromTerms() : void
- Fills up $ftsQuery and $ftsProperty property values based on the supported SearchTerm list.
- toArray() : array<string|int, mixed>
- toQuery() : string
Constants
FTS_BINARY
public
mixed
FTS_BINARY
= 'BINARY'
Properties
$class
An optional class of the for the objects returned as the search results (to be used by extension libraries).
public
string|null
$class
= null
$count
Total number of resources matching the search (despite limit/offset)
public
int|null
$count
= null
Set by RepoInterface::getGraphBy*() and RepoInterface::getResourceBy*() methods.
$ftsFragmentDelimiter
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
string|array<string|int, string>
$ftsFragmentDelimiter
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsHighlightAll
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
bool|array<string|int, bool>
$ftsHighlightAll
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsMaxFragments
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
int|array<string|int, int>
$ftsMaxFragments
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsMaxWords
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
int|array<string|int, int>
$ftsMaxWords
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsMinWords
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
int|array<string|int, int>
$ftsMinWords
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsProperty
Limits highlighting to indicated properties.
public
array<string|int, string|array<string|int, string>>
$ftsProperty
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
A value can be either a string or an array of string (meaning any of given properties).
Use SearchConfig::FTS_BINARY
to indicate binary content.
$ftsQuery
A full text search query used for search results highlighting.
public
string|array<string|int, string>
$ftsQuery
= []
See https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES and the websearch_to_tsquery() function documentation.
$ftsShortWord
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
int|array<string|int, int>
$ftsShortWord
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsStartSel
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
string|array<string|int, string>
$ftsStartSel
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$ftsStopSel
Full text search highlighting options see - https://www.postgresql.org/docs/current/textsearch-controls.html#TEXTSEARCH-HEADLINE
public
string|array<string|int, string>
$ftsStopSel
= []
If single value is used, it is applied to all FTS queries. If array is used, it has to have same length as the $ftsQuery and values are applied to corresponding queries.
$limit
Maximum number of returned resources (only resources matched by the search are counted - see `$metadataMode`).
public
int|null
$limit
= null
$metadataMode
Controls amount of metadata included in the search results.
public
string|null
$metadataMode
= null
Value should be one of RepoResourceInterface::META_*
constants
or in a form of four numbers
{children depth}_{parents depth}_{pointed to}_{pointed from}
.
Tags
$metadataParentProperty
RDF predicate used by some of metadataModes.
public
string|null
$metadataParentProperty
= null
$offset
Offset of the first returned result.
public
int|null
$offset
= null
Remember your search results must be ordered if you want get stable results.
$orderBy
List of metadata properties to order results by.
public
array<string|int, string>
$orderBy
= []
Only literal values are used for ordering.
$orderByCollation
If specified, determines the collation used for ordering the search results.
public
string|null
$orderByCollation
= null
The collation must be available for the underlying database.
$orderByLang
If specified, only property values with a given language are taken into account for ordering search matches.
public
string|null
$orderByLang
= null
$relativesProperties
List of metadata properties to fetch for relative-according-to-metadata-read-mode resources.
public
array<string|int, string>
$relativesProperties
= []
If empty, all properties are fetched.
$resourceProperties
List of metadata properties to fetch for the resource.
public
array<string|int, string>
$resourceProperties
= []
If empty, all properties are fetched.
Doesn't affect technical properties generated by the search.
$skipArtificialProperties
Should artificially generated search properties denoting search match, ordering, FTS highlighting, etc. be skipped or included.
public
bool
$skipArtificialProperties
= false
$highlightParam
private
static array<string|int, string>
$highlightParam
= ['StartSel', 'StopSel', 'MaxWords', 'MinWords', 'ShortWord', 'HighlightAll', 'MaxFragments', 'FragmentDelimiter']
Methods
factory()
Creates an instance of the SearchConfig class from the POST data or given array.
public
static factory([array<string, string>|null $src = null ]) : SearchConfig
Parameters
- $src : array<string, string>|null = null
-
source array. If not provided, $_POST is used instead.
Return values
SearchConfiggetHeaders()
Returns HTTP request headers setting metadata read mode and metadata parent property according to the search config settings.
public
getHeaders(Repo $repo) : array<string|int, string>
Parameters
- $repo : Repo
Return values
array<string|int, string>getSanitizedCopy()
Returns an object with all fts properties being arrays of the same count as the $ftsQuery property. Also, all $ftsProperty value is assured to be an array.
public
getSanitizedCopy() : self
Return values
selfgetTsHeadlineOptions()
public
getTsHeadlineOptions([int $offset = 0 ]) : string
Parameters
- $offset : int = 0
Return values
stringreadFtsConfigFromTerms()
Fills up $ftsQuery and $ftsProperty property values based on the supported SearchTerm list.
public
readFtsConfigFromTerms(array<string|int, SearchTerm> $terms) : void
Parameters
- $terms : array<string|int, SearchTerm>
toArray()
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toQuery()
public
toQuery() : string