Suggest (Completion) query builder.
More...
|
static | computeHardLimit ( $limit, $offset, SearchConfig $config) |
| Get the hard limit The completion api does not supports offset we have to add a hack here to work around this limitation.
|
|
|
const | VARIANT_EXTRA_DISCOUNT = 0.0001 |
|
|
| buildVariantProfile (array $profile, $extraDiscount=0.0001) |
| Creates a copy of $profile[$name] with a custom '-variant-SEQ' suffix.
|
|
Suggest (Completion) query builder.
Unlike classic query builders it will :
- handle limit differently as offsets are not accepted during suggest queries
- store a mutable state in mergedProfiles
◆ __construct()
CirrusSearch\Query\CompSuggestQueryBuilder::__construct |
( |
SearchContext | $context, |
|
|
array | $profile, |
|
|
| $limit, |
|
|
| $offset = 0 ) |
- Parameters
-
SearchContext | $context | |
array | $profile | settings as definied in profiles/SuggestProfiles.config.php |
int | $limit | the number of results to display |
int | $offset | |
◆ areResultsPossible()
CirrusSearch\Query\CompSuggestQueryBuilder::areResultsPossible |
( |
| ) |
|
Check the builder settings to determine if results are possible.
If this method returns false the query must not have to be sent to elastic
- Returns
- bool true if results are possible false otherwise
◆ build()
CirrusSearch\Query\CompSuggestQueryBuilder::build |
( |
| $term, |
|
|
| $variants = null ) |
Build the suggest query.
- Parameters
-
string | $term | |
string[] | null | $variants | |
- Returns
- Suggest
◆ buildVariantProfile()
CirrusSearch\Query\CompSuggestQueryBuilder::buildVariantProfile |
( |
array | $profile, |
|
|
| $extraDiscount = 0.0001 ) |
|
protected |
Creates a copy of $profile[$name] with a custom '-variant-SEQ' suffix.
And applies an extra discount factor of 0.0001. The copy is added to the profiles container.
- Parameters
-
array | $profile | profile to copy |
float | $extraDiscount | extra discount factor to rank variant suggestion lower. |
- Returns
- array
◆ computeHardLimit()
static CirrusSearch\Query\CompSuggestQueryBuilder::computeHardLimit |
( |
| $limit, |
|
|
| $offset, |
|
|
SearchConfig | $config ) |
|
static |
Get the hard limit The completion api does not supports offset we have to add a hack here to work around this limitation.
To avoid ridiculously large queries we set also a hard limit. Note that this limit will be changed by fetch_limit_factor set to 2 or 1.5 depending on the profile.
- Parameters
-
int | $limit | limit requested |
int | $offset | offset requested |
SearchConfig | $config | |
- Returns
- int the number of results to fetch from elastic
◆ getLimit()
CirrusSearch\Query\CompSuggestQueryBuilder::getLimit |
( |
| ) |
|
Number of results we could display.
- Returns
- int
◆ getMergedProfiles()
CirrusSearch\Query\CompSuggestQueryBuilder::getMergedProfiles |
( |
| ) |
|
(public for tests)
- Returns
- array
◆ postProcess()
Post process the response from elastic to build the SearchSuggestionSet.
Merge top level multi-queries and resolve returned pageIds into Title objects.
- Parameters
-
CompletionResultsCollector | $collector | |
ResultSet | $results | |
string | $indexName | |
- Returns
- int total hits
The documentation for this class was generated from the following file:
- includes/Query/CompSuggestQueryBuilder.php