CirrusSearch
Elasticsearch-powered search for MediaWiki
|
Definition of a search keyword. More...
Public Member Functions | |
getKeywordPrefixes () | |
List of keyword strings this implementation consumes. | |
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) | |
Get support strategy for cross searching. | |
expand (KeywordFeatureNode $node, SearchConfig $config, WarningCollector $warningCollector) | |
Expand the keyword potentially accessing external resources. | |
apply (SearchContext $context, $term) | |
Checks $term for usage of the feature, and applies necessary filters, rescores, etc. | |
Definition of a search keyword.
This interface is being actively refactored, the initial behavior is to do all the work in the function apply( SearchContext $context, $term ).
The aim is to clearly separate the parsing logic from the query building logic.
The parsing behavior can be defined using the following methods:
The keyword can define its CrossSearchStrategy to decide whether or not a query using this keyword can be applied to external wikis indices.
For keywords that need to fetch data from external resource the method expand( KeywordFeatureNode $node, SearchConfig $config, WarningCollector $warningCollector ) can be used. Its return value will be made in a context available during query building.
A keyword must not directly implement this interface but extends SimpleKeywordFeature.
NOTE: since this interface is being refactored it's highly recommended to use and implement the dedicated method in the old all-in-one apply strategy (This "apply" strategy will be removed).
CirrusSearch\Query\KeywordFeature::allowEmptyValue | ( | ) |
Whether this keyword allows empty value.
Implemented in CirrusSearch\Query\PreferRecentFeature, and CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::apply | ( | SearchContext | $context, |
$term ) |
Checks $term for usage of the feature, and applies necessary filters, rescores, etc.
to the provided $context. The returned $term will be passed on to other keyword features, and eventually to an elasticsearch QueryString query.
SearchContext | $context | |
string | $term | The input search query |
Implemented in CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::expand | ( | KeywordFeatureNode | $node, |
SearchConfig | $config, | ||
WarningCollector | $warningCollector ) |
Expand the keyword potentially accessing external resources.
Keywords that need to access the DB or any other external resources should implement this method. NOTE: this method will be called on every external wikis the search request will be made to.
KeywordFeatureNode | $node | |
SearchConfig | $config | |
WarningCollector | $warningCollector |
Implemented in CirrusSearch\Query\DeepcatFeature, CirrusSearch\Query\InCategoryFeature, CirrusSearch\Query\MoreLikeFeature, and CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::getCrossSearchStrategy | ( | KeywordFeatureNode | $node | ) |
Get support strategy for cross searching.
KeywordFeatureNode | $node |
Implemented in CirrusSearch\Query\BaseRegexFeature, CirrusSearch\Query\BoostTemplatesFeature, CirrusSearch\Query\ContentModelFeature, CirrusSearch\Query\DeepcatFeature, CirrusSearch\Query\FileTypeFeature, CirrusSearch\Query\HasTemplateFeature, CirrusSearch\Query\InCategoryFeature, CirrusSearch\Query\IndexedNumericFieldFeature, CirrusSearch\Query\LanguageFeature, CirrusSearch\Query\LinksToFeature, CirrusSearch\Query\LocalFeature, CirrusSearch\Query\MoreLikeFeature, CirrusSearch\Query\PreferRecentFeature, CirrusSearch\Query\PrefixFeature, CirrusSearch\Query\SimpleKeywordFeature, CirrusSearch\Query\SubPageOfFeature, and CirrusSearch\Query\TextFieldFilterFeature.
CirrusSearch\Query\KeywordFeature::getFeatureName | ( | $key, | |
$valueDelimiter ) |
Determine the name of the feature being set in SearchContext::addSyntaxUsed Defaults to $key.
string | $key | |
string | $valueDelimiter | the delimiter used to wrap the value |
Implemented in CirrusSearch\Query\BaseRegexFeature, CirrusSearch\Query\DeepcatFeature, CirrusSearch\Query\MoreLikeFeature, CirrusSearch\Query\MoreLikeThisFeature, and CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::getKeywordPrefixes | ( | ) |
List of keyword strings this implementation consumes.
Implemented in CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::getValueDelimiters | ( | ) |
List of value delimiters supported (must be an array of single byte char)
Implemented in CirrusSearch\Query\BaseRegexFeature, and CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::greedy | ( | ) |
Whether this keyword is greedy consuming the rest of the string.
NOTE: do not use, greedy keywords will eventually be removed in the future
Implemented in CirrusSearch\Query\MoreLikeFeature, CirrusSearch\Query\PrefixFeature, and CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::hasValue | ( | ) |
Whether this keyword can have a value.
Implemented in CirrusSearch\Query\LocalFeature, and CirrusSearch\Query\SimpleKeywordFeature.
CirrusSearch\Query\KeywordFeature::parseValue | ( | $key, | |
$value, | |||
$quotedValue, | |||
$valueDelimiter, | |||
$suffix, | |||
WarningCollector | $warningCollector ) |
Parse the value of the keyword.
NOTE: this function called prior to creating the node in the AST. It is not allowed to call external resources here (db, elastic, others). The data known by this method should only be the value contained in the user query string and maybe few config vars for sanity check purposes.
string | $key | The keyword |
string | $value | The value attached to the keyword with quotes stripped and escaped quotes un-escaped. |
string | $quotedValue | The original value in the search string, including quotes if used |
string | $valueDelimiter | the delimiter char used to wrap the keyword value ('"' in intitle:"test") |
string | $suffix | the optional suffix used after the value ('i' in insource:/regex/i) |
WarningCollector | $warningCollector |
Implemented in CirrusSearch\Query\ArticleTopicFeature, CirrusSearch\Query\BaseRegexFeature, CirrusSearch\Query\BoostTemplatesFeature, CirrusSearch\Query\FileTypeFeature, CirrusSearch\Query\HasRecommendationFeature, CirrusSearch\Query\HasTemplateFeature, CirrusSearch\Query\InCategoryFeature, CirrusSearch\Query\IndexedNumericFieldFeature, CirrusSearch\Query\LanguageFeature, CirrusSearch\Query\PageIdFeature, CirrusSearch\Query\PreferRecentFeature, CirrusSearch\Query\PrefixFeature, CirrusSearch\Query\SimpleKeywordFeature, and CirrusSearch\Query\SubPageOfFeature.
CirrusSearch\Query\KeywordFeature::queryHeader | ( | ) |
Whether this keyword can appear only at the beginning of the query (excluding spaces)
Implemented in CirrusSearch\Query\LocalFeature, CirrusSearch\Query\MoreLikeFeature, and CirrusSearch\Query\SimpleKeywordFeature.