CirrusSearch
Elasticsearch-powered search for MediaWiki
|
The search context, maintains the state of the current search query. More...
Public Member Functions | |
__construct (SearchConfig $config, ?array $namespaces=null, ?CirrusDebugOptions $options=null, ?FallbackRunner $fallbackRunner=null, ?FetchPhaseConfigBuilder $fetchPhaseConfigBuilder=null, ?CirrusSearchHookRunner $cirrusSearchHookRunner=null) | |
withConfig (SearchConfig $config) | |
Return a copy of this context with a new configuration. | |
__clone () | |
isDirty () | |
Have custom options that effect the search results been set outside the defaults from config? | |
getConfig () | |
getNamespaces () | |
mediawiki namespace id's being requested. | |
setNamespaces ( $namespaces) | |
set the mediawiki namespace id's | |
getProfileContext () | |
getProfileContextParams () | |
setProfileContext ( $profileContext, array $contextParams=[]) | |
getRescoreProfile () | |
setRescoreProfile ( $rescoreProfile) | |
areResultsPossible () | |
setResultsPossible ( $possible) | |
isSyntaxUsed ( $type=null) | |
isSpecialKeywordUsed () | |
getSyntaxUsed () | |
getSyntaxDescription () | |
addSyntaxUsed ( $feature, $weight=null) | |
getSearchType () | |
addFilter (AbstractQuery $filter) | |
addNotFilter (AbstractQuery $filter) | |
setHighlightQuery (?AbstractQuery $query=null) | |
addNonTextHighlightQuery (AbstractQuery $query) | |
getFetchPhaseBuilder () | |
getHighlight (ResultsType $resultsType, AbstractQuery $mainQuery) | |
getRescore () | |
rescore_query has to be in array form before we send it to Elasticsearch but it is way easier to work with if we leave it in query form until now | |
getQuery () | |
setMainQuery (AbstractQuery $query) | |
addNonTextQuery (\Elastica\Query\AbstractQuery $match) | |
getSearchQuery () | |
getLimitSearchToLocalWiki () | |
setLimitSearchToLocalWiki ( $localWikiOnly) | |
getCacheTtl () | |
setCacheTtl ( $ttl) | |
getOriginalSearchTerm () | |
setOriginalSearchTerm ( $term) | |
getCleanedSearchTerm () | |
setCleanedSearchTerm ( $term) | |
escaper () | |
getExtraScoreBuilders () | |
addCustomRescoreComponent (BoostFunctionBuilder $rescore) | |
Add custom scoring function to the context. | |
addWarning ( $message,... $params) | |
getWarnings () | |
getFulltextQueryBuilderProfile () | |
setFulltextQueryBuilderProfile ( $profile) | |
setResultsType ( $resultsType) | |
getResultsType () | |
getExtraIndices () | |
Get the list of extra indices to query. | |
getPhraseRescoreQuery () | |
Get the phrase rescore query if available. | |
setPhraseRescoreQuery ( $phraseRescoreQuery) | |
addAggregation (AbstractAggregation $agg) | |
Add aggregation to perform on search. | |
getAggregations () | |
Get the list of aggregations. | |
getDebugOptions () | |
getFilters () | |
NOTE: public for testing purposes. | |
must (AbstractQuery $query) | |
mustNot (AbstractQuery $query) | |
getFallbackRunner () | |
setTrackTotalHits (bool $trackTotalHits) | |
getTrackTotalHits () | |
Static Public Member Functions | |
static | fromSearchQuery (SearchQuery $query, ?FallbackRunner $fallbackRunner=null, ?CirrusSearchHookRunner $cirrusSearchHookRunner=null) |
Builds a SearchContext based on a SearchQuery. | |
The search context, maintains the state of the current search query.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. http://www.gnu.org/copyleft/gpl.html The SearchContext stores the various states maintained during the query building process.
CirrusSearch\Search\SearchContext::__construct | ( | SearchConfig | $config, |
?array | $namespaces = null, | ||
?CirrusDebugOptions | $options = null, | ||
?FallbackRunner | $fallbackRunner = null, | ||
?FetchPhaseConfigBuilder | $fetchPhaseConfigBuilder = null, | ||
?CirrusSearchHookRunner | $cirrusSearchHookRunner = null ) |
SearchConfig | $config | |
int[] | null | $namespaces | |
CirrusDebugOptions | null | $options | |
FallbackRunner | null | $fallbackRunner | |
FetchPhaseConfigBuilder | null | $fetchPhaseConfigBuilder | |
CirrusSearchHookRunner | null | $cirrusSearchHookRunner |
CirrusSearch\Search\SearchContext::addAggregation | ( | AbstractAggregation | $agg | ) |
Add aggregation to perform on search.
AbstractAggregation | $agg |
CirrusSearch\Search\SearchContext::addCustomRescoreComponent | ( | BoostFunctionBuilder | $rescore | ) |
Add custom scoring function to the context.
The rescore builder will pick it up.
BoostFunctionBuilder | $rescore |
CirrusSearch\Search\SearchContext::addFilter | ( | AbstractQuery | $filter | ) |
AbstractQuery | $filter | Query results must match this filter |
CirrusSearch\Search\SearchContext::addNonTextHighlightQuery | ( | AbstractQuery | $query | ) |
AbstractQuery | $query | queries that don't use Elastic's "query string" query, for more advanced highlighting (e.g. match_phrase_prefix for regular quoted strings). |
CirrusSearch\Search\SearchContext::addNonTextQuery | ( | \Elastica\Query\AbstractQuery | $match | ) |
\Elastica\Query\AbstractQuery | $match | Queries that don't use Elastic's "query string" query, for more advanced searching (e.g. match_phrase_prefix for regular quoted strings). |
CirrusSearch\Search\SearchContext::addNotFilter | ( | AbstractQuery | $filter | ) |
AbstractQuery | $filter | Query results must not match this filter |
CirrusSearch\Search\SearchContext::addSyntaxUsed | ( | $feature, | |
$weight = null ) |
string | $feature | Name of a syntax feature used in the query string |
int | null | $weight | How "complex" is this feature. |
CirrusSearch\Search\SearchContext::addWarning | ( | $message, | |
$params ) |
string | $message | i18n message key |
mixed | ...$params |
Implements CirrusSearch\WarningCollector.
CirrusSearch\Search\SearchContext::areResultsPossible | ( | ) |
CirrusSearch\Search\SearchContext::escaper | ( | ) |
|
static |
Builds a SearchContext based on a SearchQuery.
Helper function used for building blocks that still work on top of the SearchContext+queryString instead of SearchQuery.
States initialized:
suggestion
SearchQuery | $query | |
FallbackRunner | null | $fallbackRunner | |
CirrusSearchHookRunner | null | $cirrusSearchHookRunner |
CirrusSearch\Parser\ParsedQueryClassifierException
CirrusSearch\Search\SearchContext::getAggregations | ( | ) |
Get the list of aggregations.
CirrusSearch\Search\SearchContext::getCacheTtl | ( | ) |
CirrusSearch\Search\SearchContext::getCleanedSearchTerm | ( | ) |
CirrusSearch\Search\SearchContext::getConfig | ( | ) |
CirrusSearch\Search\SearchContext::getDebugOptions | ( | ) |
CirrusSearch\Search\SearchContext::getExtraIndices | ( | ) |
Get the list of extra indices to query.
Generally needed to query externilized file index. Must be called only once the list of namespaces has been set.
CirrusSearch\Search\SearchContext::getExtraScoreBuilders | ( | ) |
CirrusSearch\Search\SearchContext::getFallbackRunner | ( | ) |
CirrusSearch\Search\SearchContext::getFetchPhaseBuilder | ( | ) |
CirrusSearch\Search\SearchContext::getFilters | ( | ) |
NOTE: public for testing purposes.
CirrusSearch\Search\SearchContext::getFulltextQueryBuilderProfile | ( | ) |
CirrusSearch\Search\SearchContext::getHighlight | ( | ResultsType | $resultsType, |
AbstractQuery | $mainQuery ) |
ResultsType | $resultsType | |
AbstractQuery | $mainQuery | Will be combined with highlighting query to provide highlightable terms. |
CirrusSearch\Search\SearchContext::getLimitSearchToLocalWiki | ( | ) |
CirrusSearch\Search\SearchContext::getNamespaces | ( | ) |
mediawiki namespace id's being requested.
NOTE: this value may change during the Searcher process.
CirrusSearch\Search\SearchContext::getOriginalSearchTerm | ( | ) |
CirrusSearch\Search\SearchContext::getPhraseRescoreQuery | ( | ) |
Get the phrase rescore query if available.
CirrusSearch\Search\SearchContext::getProfileContext | ( | ) |
CirrusSearch\Search\SearchContext::getProfileContextParams | ( | ) |
CirrusSearch\Search\SearchContext::getQuery | ( | ) |
CirrusSearch\Search\SearchContext::getRescore | ( | ) |
rescore_query has to be in array form before we send it to Elasticsearch but it is way easier to work with if we leave it in query form until now
CirrusSearch\Search\SearchContext::getRescoreProfile | ( | ) |
CirrusSearch\Search\SearchContext::getResultsType | ( | ) |
CirrusSearch\Search\SearchContext::getSearchQuery | ( | ) |
CirrusSearch\Search\SearchContext::getSearchType | ( | ) |
CirrusSearch\Search\SearchContext::getSyntaxDescription | ( | ) |
CirrusSearch\Search\SearchContext::getSyntaxUsed | ( | ) |
CirrusSearch\Search\SearchContext::getWarnings | ( | ) |
CirrusSearch\Search\SearchContext::isDirty | ( | ) |
Have custom options that effect the search results been set outside the defaults from config?
CirrusSearch\Search\SearchContext::isSpecialKeywordUsed | ( | ) |
CirrusSearch\Search\SearchContext::isSyntaxUsed | ( | $type = null | ) |
string | null | $type | type of syntax to check, null for any type |
CirrusSearch\Search\SearchContext::must | ( | AbstractQuery | $query | ) |
AbstractQuery | $query |
Implements CirrusSearch\Query\Builder\FilterBuilder.
CirrusSearch\Search\SearchContext::mustNot | ( | AbstractQuery | $query | ) |
AbstractQuery | $query |
Implements CirrusSearch\Query\Builder\FilterBuilder.
CirrusSearch\Search\SearchContext::setCacheTtl | ( | $ttl | ) |
int | $ttl | The number of seconds to cache results for |
CirrusSearch\Search\SearchContext::setCleanedSearchTerm | ( | $term | ) |
string | $term | The search term with keywords removed |
CirrusSearch\Search\SearchContext::setFulltextQueryBuilderProfile | ( | $profile | ) |
string | $profile | set the name of the fulltext query builder profile |
CirrusSearch\Search\SearchContext::setHighlightQuery | ( | ?AbstractQuery | $query = null | ) |
AbstractQuery | null | $query | Query that should be used for highlighting if different from the query used for selecting. |
CirrusSearch\Search\SearchContext::setLimitSearchToLocalWiki | ( | $localWikiOnly | ) |
bool | $localWikiOnly | Should this search limit results to the local wiki? If not called the default is false. |
CirrusSearch\Search\SearchContext::setMainQuery | ( | AbstractQuery | $query | ) |
AbstractQuery | $query | The primary query to be passed to elasticsearch. |
CirrusSearch\Search\SearchContext::setNamespaces | ( | $namespaces | ) |
set the mediawiki namespace id's
int[] | null | $namespaces | array of integer |
CirrusSearch\Search\SearchContext::setOriginalSearchTerm | ( | $term | ) |
string | $term |
CirrusSearch\Search\SearchContext::setPhraseRescoreQuery | ( | $phraseRescoreQuery | ) |
AbstractQuery | null | $phraseRescoreQuery |
CirrusSearch\Search\SearchContext::setProfileContext | ( | $profileContext, | |
array | $contextParams = [] ) |
string | $profileContext | |
string[] | $contextParams |
CirrusSearch\Search\SearchContext::setRescoreProfile | ( | $rescoreProfile | ) |
string | $rescoreProfile | the rescore profile to use |
CirrusSearch\Search\SearchContext::setResultsPossible | ( | $possible | ) |
bool | $possible | Could this query possible return results? Defaults to true if not called. |
CirrusSearch\Search\SearchContext::setResultsType | ( | $resultsType | ) |
ResultsType | $resultsType | results type to return |
CirrusSearch\Search\SearchContext::withConfig | ( | SearchConfig | $config | ) |
Return a copy of this context with a new configuration.
SearchConfig | $config | The new configuration |