Constants

SORT_SCORE

SORT_SCORE

SORT_FREQUENCY

SORT_FREQUENCY

SUGGEST_MODE_MISSING

SUGGEST_MODE_MISSING

SUGGEST_MODE_ALWAYS

SUGGEST_MODE_ALWAYS

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

Filter 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

count()

count() : integer

{@inheritdoc}

Returns

integer

setAnalyzer()

setAnalyzer(string  $analyzer) : $this

Parameters

string $analyzer

Returns

$this

setSort()

setSort(string  $sort) : $this

Parameters

string $sort

see SORT_* constants for options

Returns

$this

setSuggestMode()

setSuggestMode(string  $mode) : $this

Parameters

string $mode

see SUGGESTMODE* constants for options

Returns

$this

setLowercaseTerms()

setLowercaseTerms(boolean  $lowercase = true) : $this

If true, suggest terms will be lower cased after text analysis.

Parameters

boolean $lowercase

Returns

$this

setMaxEdits()

setMaxEdits(integer  $max = 2) : $this

Set the maximum edit distance candidate suggestions can have in order to be considered as a suggestion.

Parameters

integer $max

Either 1 or 2. Any other value will result in an error.

Returns

$this

setPrefixLength()

setPrefixLength(integer  $length = 1) : $this

The number of minimum prefix characters that must match in order to be a suggestion candidate.

Parameters

integer $length

defaults to 1

Returns

$this

setMinWordLength()

setMinWordLength(integer  $length = 4) : $this

The minimum length a suggest text term must have in order to be included.

Parameters

integer $length

defaults to 4

Returns

$this

setMaxInspections()

setMaxInspections(integer  $max = 5) : $this

Parameters

integer $max

defaults to 5

Returns

$this

setMinDocFrequency()

setMinDocFrequency(integer|float  $min) : $this

Set the minimum number of documents in which a suggestion should appear.

Parameters

integer|float $min

Defaults to 0. If the value is greater than 1, it must be a whole number.

Returns

$this

setMaxTermFrequency()

setMaxTermFrequency(float  $max = 0.01) : $this

Set the maximum number of documents in which a suggest text token can exist in order to be included.

Parameters

float $max

Returns

$this

setStringDistanceAlgorithm()

setStringDistanceAlgorithm(string  $distanceAlgorithm) : $this

Which string distance implementation to use for comparing how similar suggested terms are.

Five possible values can be specified:.

  • internal
  • damerau_levenshtein
  • levenshtein
  • jaro_winkler
  • ngram

Parameters

string $distanceAlgorithm

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