Constants

BOOST_MODE_MULTIPLY

BOOST_MODE_MULTIPLY

BOOST_MODE_REPLACE

BOOST_MODE_REPLACE

BOOST_MODE_SUM

BOOST_MODE_SUM

BOOST_MODE_AVERAGE

BOOST_MODE_AVERAGE

BOOST_MODE_MAX

BOOST_MODE_MAX

BOOST_MODE_MIN

BOOST_MODE_MIN

SCORE_MODE_MULTIPLY

SCORE_MODE_MULTIPLY

SCORE_MODE_SUM

SCORE_MODE_SUM

SCORE_MODE_AVERAGE

SCORE_MODE_AVERAGE

SCORE_MODE_FIRST

SCORE_MODE_FIRST

SCORE_MODE_MAX

SCORE_MODE_MAX

SCORE_MODE_MIN

SCORE_MODE_MIN

DECAY_GAUSS

DECAY_GAUSS

DECAY_EXPONENTIAL

DECAY_EXPONENTIAL

DECAY_LINEAR

DECAY_LINEAR

FIELD_VALUE_FACTOR_MODIFIER_NONE

FIELD_VALUE_FACTOR_MODIFIER_NONE

FIELD_VALUE_FACTOR_MODIFIER_LOG

FIELD_VALUE_FACTOR_MODIFIER_LOG

FIELD_VALUE_FACTOR_MODIFIER_LOG1P

FIELD_VALUE_FACTOR_MODIFIER_LOG1P

FIELD_VALUE_FACTOR_MODIFIER_LOG2P

FIELD_VALUE_FACTOR_MODIFIER_LOG2P

FIELD_VALUE_FACTOR_MODIFIER_LN

FIELD_VALUE_FACTOR_MODIFIER_LN

FIELD_VALUE_FACTOR_MODIFIER_LN1P

FIELD_VALUE_FACTOR_MODIFIER_LN1P

FIELD_VALUE_FACTOR_MODIFIER_LN2P

FIELD_VALUE_FACTOR_MODIFIER_LN2P

FIELD_VALUE_FACTOR_MODIFIER_SQUARE

FIELD_VALUE_FACTOR_MODIFIER_SQUARE

FIELD_VALUE_FACTOR_MODIFIER_SQRT

FIELD_VALUE_FACTOR_MODIFIER_SQRT

FIELD_VALUE_FACTOR_MODIFIER_RECIPROCAL

FIELD_VALUE_FACTOR_MODIFIER_RECIPROCAL

MULTI_VALUE_MODE_MIN

MULTI_VALUE_MODE_MIN

MULTI_VALUE_MODE_MAX

MULTI_VALUE_MODE_MAX

MULTI_VALUE_MODE_AVG

MULTI_VALUE_MODE_AVG

MULTI_VALUE_MODE_SUM

MULTI_VALUE_MODE_SUM

RANDOM_SCORE_FIELD_ID

RANDOM_SCORE_FIELD_ID

RANDOM_SCORE_FIELD_SEQ_NO

RANDOM_SCORE_FIELD_SEQ_NO

Properties

$_params

$_params : array

Params.

Type

array

$_rawParams

$_rawParams : array

Raw Params.

Type

array

$_functions

$_functions : 

Type

Methods

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

setQuery()

setQuery(\Elastica\Query\AbstractQuery  $query) : $this

Set the child query for this function_score query.

Parameters

\Elastica\Query\AbstractQuery $query

Returns

$this

addFunction()

addFunction(string  $functionType, array|float|\Elastica\Script\AbstractScript  $functionParams, \Elastica\Query\AbstractQuery  $filter = null, float  $weight = null) : $this

Add a function to the function_score query.

Parameters

string $functionType

valid values are DECAY_* constants and script_score

array|float|\Elastica\Script\AbstractScript $functionParams

the body of the function. See documentation for proper syntax.

\Elastica\Query\AbstractQuery $filter

filter to apply to the function

float $weight

function weight

Returns

$this

addScriptScoreFunction()

addScriptScoreFunction(\Elastica\Script\AbstractScript  $script, \Elastica\Query\AbstractQuery  $filter = null, float  $weight = null) : $this

Add a script_score function to the query.

Parameters

\Elastica\Script\AbstractScript $script

a Script object

\Elastica\Query\AbstractQuery $filter

an optional filter to apply to the function

float $weight

the weight of the function

Returns

$this

addDecayFunction()

addDecayFunction(string  $function, string  $field, string  $origin, string  $scale, string  $offset = null, float  $decay = null, float  $weight = null, \Elastica\Query\AbstractQuery  $filter = null, string  $multiValueMode = null) : $this

Add a decay function to the query.

Parameters

string $function

see DECAY_* constants for valid options

string $field

the document field on which to perform the decay function

string $origin

the origin value for this decay function

string $scale

a scale to define the rate of decay for this function

string $offset

If defined, this function will only be computed for documents with a distance from the origin greater than this value

float $decay

optionally defines how documents are scored at the distance given by the $scale parameter

float $weight

optional factor by which to multiply the score at the value provided by the $scale parameter

\Elastica\Query\AbstractQuery $filter

a filter associated with this function

string $multiValueMode

see MULTI_VALUEMODE* constants for valid options

Returns

$this

addFieldValueFactorFunction()

addFieldValueFactorFunction(string  $field, float|null  $factor = null, string|null  $modifier = null, float|null  $missing = null, float|null  $weight = null, \Elastica\Query\AbstractQuery|null  $filter = null) : $this

Parameters

string $field
float|null $factor
string|null $modifier
float|null $missing
float|null $weight
\Elastica\Query\AbstractQuery|null $filter

Returns

$this

addWeightFunction()

addWeightFunction(float  $weight, \Elastica\Query\AbstractQuery  $filter = null) : $this

Parameters

float $weight

the weight of the function

\Elastica\Query\AbstractQuery $filter

a filter associated with this function

Returns

$this

addRandomScoreFunction()

addRandomScoreFunction(integer  $seed, \Elastica\Query\AbstractQuery  $filter = null, float  $weight = null, string  $field = null) : $this

Add a random_score function to the query.

Parameters

integer $seed

the seed value

\Elastica\Query\AbstractQuery $filter

a filter associated with this function

float $weight

an optional boost value associated with this function

string $field

the field to be used for random number generation

Returns

$this

setBoost()

setBoost(float  $boost) : $this

Set an overall boost value for this query.

Parameters

float $boost

Returns

$this

setMaxBoost()

setMaxBoost(float  $maxBoost) : $this

Restrict the combined boost of the function_score query and its child query.

Parameters

float $maxBoost

Returns

$this

setBoostMode()

setBoostMode(string  $mode = self::BOOST_MODE_MULTIPLY) : $this

The boost mode determines how the score of this query is combined with that of the child query.

Parameters

string $mode

see BOOSTMODE* constants for valid options. Default is multiply.

Returns

$this

setRandomScore()

setRandomScore(integer  $seed = null) : $this

If set, this query will return results in random order.

Parameters

integer $seed

set a seed value to return results in the same random order for consistent pagination

Returns

$this

setScoreMode()

setScoreMode(string  $mode = self::SCORE_MODE_MULTIPLY) : $this

Set the score method.

Parameters

string $mode

see SCOREMODE* constants for valid options. Default is multiply.

Returns

$this

setMinScore()

setMinScore(float  $minScore) : $this

Set min_score option.

Parameters

float $minScore

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