Properties

$_name

$_name : string

Type

string — the name of this suggestion

$_text

$_text : string

Type

string — the text for 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

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() : array

Converts the params to an array. A default implementation exist to create the an array out of the class name (last part of the class name) and the params.

Returns

array

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

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 = 0.4) : $this

Parameters

float $discount

Returns

$this

setLaplaceSmoothing()

setLaplaceSmoothing(float  $alpha = 0.5) : $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