Constants

DEFAULT_REAL_WORD_ERROR_LIKELIHOOD

DEFAULT_REAL_WORD_ERROR_LIKELIHOOD

DEFAULT_CONFIDENCE

DEFAULT_CONFIDENCE

DEFAULT_MAX_ERRORS

DEFAULT_MAX_ERRORS

DEFAULT_STUPID_BACKOFF_DISCOUNT

DEFAULT_STUPID_BACKOFF_DISCOUNT

DEFAULT_LAPLACE_SMOOTHING_ALPHA

DEFAULT_LAPLACE_SMOOTHING_ALPHA

Properties

$_name

$_name : string

Type

string — the name of this suggestion

$_params

$_params : array

Params.

Type

array

$_rawParams

$_rawParams : array

Raw Params.

Type

array

Methods

__construct()

__construct(string  $name, string  $field) 

Parameters

string $name
string $field

setText()

setText(string  $text) : $this

Suggest text must be set either globally or per suggestion.

Parameters

string $text

Returns

$this

setPrefix()

setPrefix(string  $prefix) : $this

Suggest prefix must be set either globally or per suggestion.

Parameters

string $prefix

Returns

$this

setRegex()

setRegex(string  $regex) : $this

Suggest regex must be set either globally or per suggestion.

Parameters

string $regex

Returns

$this

setRegexOptions()

setRegexOptions(array  $value) : $this

Expects one of the next params: max_determinized_states - defaults to 10000, flags are ALL (default), ANYSTRING, COMPLEMENT, EMPTY, INTERSECTION, INTERVAL, or NONE.

Parameters

array $value

Returns

$this

setField()

setField(string  $field) : $this

Parameters

string $field

Returns

$this

setSize()

setSize(integer  $size) : $this

Parameters

integer $size

Returns

$this

setShardSize()

setShardSize(integer  $size) : $this

Parameters

integer $size

maximum number of suggestions to be retrieved from each shard

Returns

$this

setName()

setName(string  $name) : $this

Sets the name of the suggest. It is automatically set by the constructor.

Parameters

string $name

The name of the suggest

Throws

\Elastica\Exception\InvalidException

If name is empty

Returns

$this

getName()

getName() : string

Retrieve the name of this suggestion.

Returns

string

toArray()

toArray() 

{@inheritdoc}

setParam()

setParam(string  $key, mixed  $value) : $this

Sets (overwrites) the value at the given key.

Parameters

string $key

Key to set

mixed $value

Key Value

Returns

$this

setParams()

setParams(array  $params) : $this

Sets (overwrites) all params of this object.

Parameters

array $params

Parameter list

Returns

$this

addParam()

addParam(string  $key, mixed  $value) : $this

Adds a param to the list.

This function can be used to add an array of params

Parameters

string $key

Param key

mixed $value

Value to set

Returns

$this

getParam()

getParam(string  $key) : mixed

Returns a specific param.

Parameters

string $key

Key to return

Throws

\Elastica\Exception\InvalidException

If requested key is not set

Returns

mixed —

Key value

hasParam()

hasParam(string  $key) : boolean

Test if a param is set.

Parameters

string $key

Key to test

Returns

boolean —

True if the param is set, false otherwise

getParams()

getParams() : array

Returns the params array.

Returns

array —

Params

count()

count() : integer

{@inheritdoc}

Returns

integer

setAnalyzer()

setAnalyzer(string  $analyzer) : $this

Parameters

string $analyzer

Returns

$this

setGramSize()

setGramSize(integer  $size) : $this

Set the max size of the n-grams (shingles) in the field.

Parameters

integer $size

Returns

$this

setRealWordErrorLikelihood()

setRealWordErrorLikelihood(float  $likelihood) : $this

Set the likelihood of a term being misspelled even if the term exists in the dictionary.

Parameters

float $likelihood

Defaults to 0.95, meaning 5% of the words are misspelled.

Returns

$this

setConfidence()

setConfidence(float  $confidence) : $this

Set the factor applied to the input phrases score to be used as a threshold for other suggestion candidates.

Only candidates which score higher than this threshold will be included in the result.

Parameters

float $confidence

Defaults to 1.0.

Returns

$this

setMaxErrors()

setMaxErrors(float  $max) : $this

Set the maximum percentage of the terms considered to be misspellings in order to form a correction.

Parameters

float $max

Returns

$this

setSeparator()

setSeparator(string  $separator) : $this

Parameters

string $separator

Returns

$this

setHighlight()

setHighlight(string  $preTag, string  $postTag) : $this

Set suggestion highlighting.

Parameters

string $preTag
string $postTag

Returns

$this

setStupidBackoffSmoothing()

setStupidBackoffSmoothing(float  $discount) : $this

Parameters

float $discount

Returns

$this

setLaplaceSmoothing()

setLaplaceSmoothing(float  $alpha) : $this

Parameters

float $alpha

Returns

$this

setLinearInterpolationSmoothing()

setLinearInterpolationSmoothing(float  $trigramLambda, float  $bigramLambda, float  $unigramLambda) : $this

Parameters

float $trigramLambda
float $bigramLambda
float $unigramLambda

Returns

$this

setSmoothingModel()

setSmoothingModel(string  $model, array  $params) : $this

Parameters

string $model

the name of the smoothing model

array $params

Returns

$this

_convertArrayable()

_convertArrayable(array  $array) : array

Cast objects to arrays.

Parameters

array $array

Returns

array

_getBaseName()

_getBaseName() : string

Param's name Picks the last part of the class name and makes it snake_case You can override this method if you want to change the name.

Returns

string —

name

_setRawParam()

_setRawParam(string  $key, mixed  $value) : $this

Sets params not inside params array.

Parameters

string $key
mixed $value

Returns

$this