CirrusSearch
Elasticsearch-powered search for MediaWiki
Loading...
Searching...
No Matches
CirrusSearch\Query\SimpleKeywordFeature Class Reference

Implements abstract handling of keyword features that are composed of a keyword followed by a colon then an optionally quoted value. More...

+ Inheritance diagram for CirrusSearch\Query\SimpleKeywordFeature:
+ Collaboration diagram for CirrusSearch\Query\SimpleKeywordFeature:

Public Member Functions

 getKeywordPrefixes ()
 
 allowEmptyValue ()
 Whether this keyword allows empty value.
 
 hasValue ()
 Whether this keyword can have a value.
 
 greedy ()
 Whether this keyword is greedy consuming the rest of the string.
 
 queryHeader ()
 Whether this keyword can appear only at the beginning of the query (excluding spaces)
 
 getFeatureName ( $key, $valueDelimiter)
 Determine the name of the feature being set in SearchContext::addSyntaxUsed Defaults to $key.
 
 getValueDelimiters ()
 List of value delimiters supported (must be an array of single byte char)
 
 parseValue ( $key, $value, $quotedValue, $valueDelimiter, $suffix, WarningCollector $warningCollector)
 Parse the value of the keyword.
 
 getCrossSearchStrategy (KeywordFeatureNode $node)
 
 expand (KeywordFeatureNode $node, SearchConfig $config, WarningCollector $warningCollector)
 
 doApplyExtended (SearchContext $context, $key, $value, $quotedValue, $negated, $delimiter, $suffix)
 Fully featured apply method which delegates to doApply by default.
 
 apply (SearchContext $context, $term)
 

Protected Member Functions

 getKeywords ()
 NOTE: will be removed once all implementations implement getKeywordStrings (transitional state to change the visibility of getKeywords())
 
 doApply (SearchContext $context, $key, $value, $quotedValue, $negated)
 Applies the detected keyword from the search term.
 

Detailed Description

Implements abstract handling of keyword features that are composed of a keyword followed by a colon then an optionally quoted value.

For consistency most query features should be implemented this way using the default getValueRegex() where possible.

Member Function Documentation

◆ allowEmptyValue()

CirrusSearch\Query\SimpleKeywordFeature::allowEmptyValue ( )

Whether this keyword allows empty value.

Returns
bool true to allow the keyword to appear in an empty form

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\PreferRecentFeature.

◆ apply()

CirrusSearch\Query\SimpleKeywordFeature::apply ( SearchContext $context,
$term )
Parameters
SearchContext$context
string$termSearch query
Returns
string Remaining search query

Implements CirrusSearch\Query\KeywordFeature.

◆ doApply()

CirrusSearch\Query\SimpleKeywordFeature::doApply ( SearchContext $context,
$key,
$value,
$quotedValue,
$negated )
abstractprotected

Applies the detected keyword from the search term.

May apply changes either to $context directly, or return a filter to be added.

Parameters
SearchContext$context
string$keyThe keyword
string$valueThe value attached to the keyword with quotes stripped and escaped quotes un-escaped.
string$quotedValueThe original value in the search string, including quotes if used
bool$negatedIs the search negated? Not used to generate the returned AbstractQuery, that will be negated as necessary. Used for any other building/context necessary.
Returns
array Two element array, first an AbstractQuery or null to apply to the query. Second a boolean indicating if the quotedValue should be kept in the search string.

Reimplemented in CirrusSearch\Query\ArticleTopicFeature, CirrusSearch\Query\BoostTemplatesFeature, CirrusSearch\Query\ContentModelFeature, CirrusSearch\Query\DeepcatFeature, CirrusSearch\Query\FileNumericFeature, CirrusSearch\Query\FileTypeFeature, CirrusSearch\Query\HasRecommendationFeature, CirrusSearch\Query\HasTemplateFeature, CirrusSearch\Query\InCategoryFeature, CirrusSearch\Query\InSourceFeature, CirrusSearch\Query\InTitleFeature, CirrusSearch\Query\LanguageFeature, CirrusSearch\Query\LinksToFeature, CirrusSearch\Query\LocalFeature, CirrusSearch\Query\MoreLikeFeature, CirrusSearch\Query\MoreLikeThisFeature, CirrusSearch\Query\PageIdFeature, CirrusSearch\Query\PreferRecentFeature, CirrusSearch\Query\PrefixFeature, CirrusSearch\Query\SubPageOfFeature, and CirrusSearch\Query\TextFieldFilterFeature.

◆ doApplyExtended()

CirrusSearch\Query\SimpleKeywordFeature::doApplyExtended ( SearchContext $context,
$key,
$value,
$quotedValue,
$negated,
$delimiter,
$suffix )

Fully featured apply method which delegates to doApply by default.

Parameters
SearchContext$context
string$keyThe keyword
string$valueThe value attached to the keyword with quotes stripped and escaped quotes un-escaped.
string$quotedValueThe original value in the search string, including quotes if used
bool$negatedIs the search negated? Not used to generate the returned AbstractQuery, that will be negated as necessary. Used for any other building/context necessary.
string$delimiterthe delimiter char used to wrap the keyword value ('"' in intitle:"test")
string$suffixthe optional suffix used after the value ('i' in insource:/regex/i)
Returns
array Two element array, first an AbstractQuery or null to apply to the query. Second a boolean indicating if the quotedValue should be kept in the search string.

Reimplemented in CirrusSearch\Query\BaseRegexFeature, and CirrusSearch\Query\HasTemplateFeature.

◆ expand()

CirrusSearch\Query\SimpleKeywordFeature::expand ( KeywordFeatureNode $node,
SearchConfig $config,
WarningCollector $warningCollector )
Parameters
KeywordFeatureNode$node
SearchConfig$config
WarningCollector$warningCollector
Returns
array

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\DeepcatFeature, CirrusSearch\Query\InCategoryFeature, and CirrusSearch\Query\MoreLikeFeature.

◆ getCrossSearchStrategy()

◆ getFeatureName()

CirrusSearch\Query\SimpleKeywordFeature::getFeatureName ( $key,
$valueDelimiter )

Determine the name of the feature being set in SearchContext::addSyntaxUsed Defaults to $key.

Parameters
string$key
string$valueDelimiterthe delimiter used to wrap the value
Returns
string '"' when parsing keyword:"test" '' when parsing keyword:test

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\BaseRegexFeature, CirrusSearch\Query\DeepcatFeature, CirrusSearch\Query\MoreLikeFeature, and CirrusSearch\Query\MoreLikeThisFeature.

◆ getKeywordPrefixes()

CirrusSearch\Query\SimpleKeywordFeature::getKeywordPrefixes ( )
Returns
string[]

Implements CirrusSearch\Query\KeywordFeature.

◆ getKeywords()

◆ getValueDelimiters()

CirrusSearch\Query\SimpleKeywordFeature::getValueDelimiters ( )

List of value delimiters supported (must be an array of single byte char)

Returns
string[][] list of delimiters options

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\BaseRegexFeature.

◆ greedy()

CirrusSearch\Query\SimpleKeywordFeature::greedy ( )

Whether this keyword is greedy consuming the rest of the string.

NOTE: do not override, greedy keywords will eventually be removed in the future

Returns
bool

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\MoreLikeFeature, and CirrusSearch\Query\PrefixFeature.

◆ hasValue()

CirrusSearch\Query\SimpleKeywordFeature::hasValue ( )

Whether this keyword can have a value.

Returns
bool

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\LocalFeature.

◆ parseValue()

CirrusSearch\Query\SimpleKeywordFeature::parseValue ( $key,
$value,
$quotedValue,
$valueDelimiter,
$suffix,
WarningCollector $warningCollector )

Parse the value of the keyword.

Parameters
string$key
string$value
string$quotedValue
string$valueDelimiter
string$suffix
WarningCollector$warningCollector
Returns
array|null|false null when nothing is to be kept, false when the value is refused (only allowed for keywords that allows empty value)
See also
self::allowEmptyValue

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\ArticleTopicFeature, CirrusSearch\Query\BaseRegexFeature, CirrusSearch\Query\BoostTemplatesFeature, CirrusSearch\Query\FileNumericFeature, CirrusSearch\Query\FileTypeFeature, CirrusSearch\Query\HasRecommendationFeature, CirrusSearch\Query\HasTemplateFeature, CirrusSearch\Query\InCategoryFeature, CirrusSearch\Query\LanguageFeature, CirrusSearch\Query\PageIdFeature, CirrusSearch\Query\PreferRecentFeature, CirrusSearch\Query\PrefixFeature, and CirrusSearch\Query\SubPageOfFeature.

◆ queryHeader()

CirrusSearch\Query\SimpleKeywordFeature::queryHeader ( )

Whether this keyword can appear only at the beginning of the query (excluding spaces)

Returns
bool

Implements CirrusSearch\Query\KeywordFeature.

Reimplemented in CirrusSearch\Query\LocalFeature, and CirrusSearch\Query\MoreLikeFeature.


The documentation for this class was generated from the following file: