CirrusSearch
Elasticsearch-powered search for MediaWiki
Loading...
Searching...
No Matches
CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder Class Reference

Simple class for SuggestionsBuilder that needs to munge the title into a list of "subphrases" suggestions. More...

+ Inheritance diagram for CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder:
+ Collaboration diagram for CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder:

Public Member Functions

 __construct ( $charRange, $maxSubPhrases=self::MAX_SUBPHRASES)
 
 getRequiredFields ()
 @inheritDoc
 
 build (array $inputDoc, $suggestType, $score, \Elastica\Document $suggestDoc, $targetNamespace)
 
 splitTranslatedPage ( $title, $language)
 Split a translated page title into an array with the title at offset 0 and the language subpage at offset 1.
 
 tokenize ( $title, $language)
 Tokenize the input $title by generating phrases suited for completion search.
 

Static Public Member Functions

static create (array $config)
 

Public Attributes

const SUBPAGE_TYPE = 'subpage'
 @const string subpage type
 
const STARTS_WITH_ANY_WORDS_TYPE = 'anywords'
 @const string subpage type
 

Protected Member Functions

 getCharRange ()
 Get the char range used by this builder to split and generate subphrase suggestions.
 
 getExtraFields ()
 List of FST fields where the subphrase suggestions will be added.
 

Detailed Description

Simple class for SuggestionsBuilder that needs to munge the title into a list of "subphrases" suggestions.

Subphrases are only generated for title, redirects are not yet supported. A set of new fields is used to insert these suggestions 'suggest-extra' is used by default but can be overridden with string[] getExtraFields().

Constructor & Destructor Documentation

◆ __construct()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::__construct ( $charRange,
$maxSubPhrases = self::MAX_SUBPHRASES )
Parameters
string$charRangecharacter range used to split subphrases
int$maxSubPhrasesdefaults to MAX_SUBPHRASES

Member Function Documentation

◆ build()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::build ( array $inputDoc,
$suggestType,
$score,
\Elastica\Document $suggestDoc,
$targetNamespace )
Parameters
mixed[]$inputDoc
string$suggestType(title or redirect)
int$score
\Elastica\Document$suggestDocsuggestion type (title or redirect)
int$targetNamespace

Implements CirrusSearch\BuildDocument\Completion\ExtraSuggestionsBuilder.

◆ getCharRange()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::getCharRange ( )
protected

Get the char range used by this builder to split and generate subphrase suggestions.

Returns
string a valid regex char range that will be inserted inside square brackets.

◆ getExtraFields()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::getExtraFields ( )
protected

List of FST fields where the subphrase suggestions will be added.

Returns
string[]

◆ getRequiredFields()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::getRequiredFields ( )

◆ splitTranslatedPage()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::splitTranslatedPage ( $title,
$language )

Split a translated page title into an array with the title at offset 0 and the language subpage at offset 1.

e.g. splitTranslatedPage("Hello/en", "en")

  • will output [ "Hello", "/en" ] e.g. splitTranslatedPage("Hello/test", "en")
  • will output [ "Hello/test", "" ]
Parameters
string$title
string$language
Returns
string[]

◆ tokenize()

CirrusSearch\BuildDocument\Completion\NaiveSubphrasesSuggestionsBuilder::tokenize ( $title,
$language )

Tokenize the input $title by generating phrases suited for completion search.

e.g. : $title = "Hello Beautifull Word/en"; $builder->tokenize( $title, "en", "\\s" ); will generate the following array: [ "Beautifull Word/en", "Word/en" ]

Parameters
string$title
string$language
Returns
string[] tokenized phrasal suggestions

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