Properties

$_params

$_params : array

Params.

Type

array

$_rawParams

$_rawParams : array

Raw Params.

Type

array

$_string

$_string : string

Query string.

Type

string

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

factory()

factory(string  $string = null) : self

Factory method.

Parameters

string $string

JSON encoded string to use as query.

Returns

self

__construct()

__construct(string  $string = null) 

Constructor.

Parameters

string $string

JSON encoded string to use as query.

__toString()

__toString() : string

Output the query string.

Returns

string

allowLeadingWildcard()

allowLeadingWildcard(boolean  $bool = true) : $this

Allow wildcards (*, ?) as the first character in a query.

Parameters

boolean $bool

Defaults to true.

Returns

$this

analyzeWildcard()

analyzeWildcard(boolean  $bool = true) : $this

Enable best effort analysis of wildcard terms.

Parameters

boolean $bool

Defaults to true.

Returns

$this

analyzer()

analyzer(string  $analyzer) : $this

Set the analyzer name used to analyze the query string.

Parameters

string $analyzer

Analyzer to use.

Returns

$this

autoGeneratePhraseQueries()

autoGeneratePhraseQueries(boolean  $bool = true) : $this

Autogenerate phrase queries.

Parameters

boolean $bool

Defaults to true.

Returns

$this

bool()

bool() : $this

Bool Query.

A query that matches documents matching boolean combinations of other queries.

The bool query maps to Lucene BooleanQuery.

It is built using one or more boolean clauses, each clause with a typed occurrence.

The occurrence types are: must, should, must_not.

Returns

$this

boolClose()

boolClose() : $this

Close a 'bool' block.

Alias of close() for ease of reading in source.

Returns

$this

boost()

boost(float  $boost = 1.0) : $this

Sets the boost value of the query.

Parameters

float $boost

Defaults to 1.0.

Returns

$this

close()

close() : $this

Close a previously opened brace.

Returns

$this

constantScore()

constantScore() : $this

Constant Score Query.

A query that wraps a filter or another query and simply returns a constant score equal to the query boost for every document in the filter.

Maps to Lucene ConstantScoreQuery.

Returns

$this

constantScoreClose()

constantScoreClose() : $this

Close a 'constant_score' block.

Alias of close() for ease of reading in source.

Returns

$this

defaultField()

defaultField(string  $field = '_all') : $this

The default field for query terms if no prefix field is specified.

Parameters

string $field

Defaults to _all.

Returns

$this

defaultOperator()

defaultOperator(string  $operator = 'OR') : $this

The default operator used if no explicit operator is specified.

For example, with a default operator of OR, the query "capital of Hungary" is translated to "capital OR of OR Hungary", and with default operator of AND, the same query is translated to "capital AND of AND Hungary".

Parameters

string $operator

Defaults to OR.

Returns

$this

disMax()

disMax() : $this

Dis Max Query.

A query that generates the union of documents produced by its subqueries, and that scores each document with the maximum score for that document as produced by any subquery, plus a tie breaking increment for any additional matching subqueries.

Returns

$this

disMaxClose()

disMaxClose() : $this

Close a 'dis_max' block.

Alias of close() for ease of reading in source.

Returns

$this

enablePositionIncrements()

enablePositionIncrements(boolean  $bool = true) : $this

Enable position increments in result queries.

Parameters

boolean $bool

Defaults to true.

Returns

$this

explain()

explain(boolean  $value = true) : $this

Enables explanation for each hit on how its score was computed.

Parameters

boolean $value

Turn on / off explain.

Returns

$this

field()

field(string  $name, mixed  $value) : $this

Add a specific field / value entry.

Parameters

string $name

Field to add.

mixed $value

Value to set.

Returns

$this

fieldClose()

fieldClose() : $this

Close a field block.

Alias of close() for ease of reading in source. Passed parameters will be ignored, however they can be useful in source for seeing which field is being closed.

Builder::factory() ->query() ->range() ->fieldOpen('created') ->gte('2011-07-18 00:00:00') ->lt('2011-07-19 00:00:00') ->fieldClose('created') ->rangeClose() ->queryClose();

Returns

$this

fieldOpen()

fieldOpen(string  $name) : $this

Open a node for the specified name.

Parameters

string $name

Field name.

Returns

$this

fields()

fields(array  $fields) : $this

Explicitly define fields to return.

Parameters

array $fields

Array of fields to return.

Returns

$this

filter()

filter() : $this

Open a 'filter' block.

Returns

$this

filterClose()

filterClose() : $this

Close a filter block.

Returns

$this

filteredQuery()

filteredQuery() : $this

Query.

Returns

$this

filteredQueryClose()

filteredQueryClose() : $this

Close a 'filtered_query' block.

Alias of close() for ease of reading in source.

Returns

$this

from()

from(integer  $value) : $this

Set the from parameter (offset).

Parameters

integer $value

Result number to start from.

Returns

$this

fuzzyMinSim()

fuzzyMinSim(float  $value = 0.5) : $this

Set the minimum similarity for fuzzy queries.

Parameters

float $value

Defaults to 0.5.

Returns

$this

fuzzyPrefixLength()

fuzzyPrefixLength(integer  $value) : $this

Set the prefix length for fuzzy queries.

Parameters

integer $value

Defaults to 0.

Returns

$this

gt()

gt(mixed  $value) : $this

Add a greater than (gt) clause.

Used in range blocks.

Parameters

mixed $value

Value to be gt.

Returns

$this

gte()

gte(mixed  $value) : $this

Add a greater than or equal to (gte) clause.

Used in range blocks.

Parameters

mixed $value

Value to be gte to.

Returns

$this

lowercaseExpandedTerms()

lowercaseExpandedTerms(boolean  $bool = true) : $this

Automatically lower-case terms of wildcard, prefix, fuzzy, and range queries.

Parameters

boolean $bool

Defaults to true.

Returns

$this

lt()

lt(mixed  $value) : $this

Add a less than (lt) clause.

Used in range blocks.

Parameters

mixed $value

Value to be lt.

Returns

$this

lte()

lte(mixed  $value) : $this

Add a less than or equal to (lte) clause.

Used in range blocks.

Parameters

mixed $value

Value to be lte to.

Returns

$this

matchAll()

matchAll(float  $boost = null) : $this

Match All Query.

A query that matches all documents.

Maps to Lucene MatchAllDocsQuery.

Parameters

float $boost

Boost to use.

Returns

$this

minimumNumberShouldMatch()

minimumNumberShouldMatch(integer  $minimum) : $this

The minimum number of should clauses to match.

Parameters

integer $minimum

Minimum number that should match.

Returns

$this

must()

must() : $this

The clause (query) must appear in matching documents.

Returns

$this

mustClose()

mustClose() : $this

Close a 'must' block.

Alias of close() for ease of reading in source.

Returns

$this

mustNot()

mustNot() : $this

The clause (query) must not appear in the matching documents.

Note that it is not possible to search on documents that only consists of a must_not clauses.

Returns

$this

mustNotClose()

mustNotClose() : $this

Close a 'must_not' block.

Alias of close() for ease of reading in source.

Returns

$this

open()

open() : $this

Add an opening brace.

Returns

$this

phraseSlop()

phraseSlop(integer  $value) : $this

Sets the default slop for phrases.

If zero, then exact phrase matches are required.

Parameters

integer $value

Defaults to 0.

Returns

$this

prefix()

prefix() : $this

Query.

Returns

$this

prefixClose()

prefixClose() : $this

Close a 'prefix' block.

Alias of close() for ease of reading in source.

Returns

$this

queries()

queries(array  $queries) : $this

Queries to run within a dis_max query.

Parameters

array $queries

Array of queries.

Returns

$this

query()

query() : $this

Open a query block.

Returns

$this

queryClose()

queryClose() : $this

Close a query block.

Alias of close() for ease of reading in source.

Returns

$this

queryString()

queryString() : $this

Query String Query.

A query that uses a query parser in order to parse its content

Returns

$this

queryStringClose()

queryStringClose() : $this

Close a 'query_string' block.

Alias of close() for ease of reading in source.

Returns

$this

range()

range() : $this

Open a range block.

Returns

$this

rangeClose()

rangeClose() : $this

Close a range block.

Alias of close() for ease of reading in source.

Returns

$this

should()

should() : $this

The clause (query) should appear in the matching document.

A boolean query with no must clauses, one or more should clauses must match a document.

Returns

$this

shouldClose()

shouldClose() : $this

Close a 'should' block.

Alias of close() for ease of reading in source.

Returns

$this

size()

size(integer  $value = 10) : $this

Set the size parameter (number of records to return).

Parameters

integer $value

Number of records to return.

Returns

$this

sort()

sort() : $this

Allows to add one or more sort on specific fields.

Returns

$this

sortClose()

sortClose() : $this

Close a sort block.

Alias of close() for ease of reading in source.

Returns

$this

sortField()

sortField(string  $name, boolean  $reverse = false) : $this

Add a field to sort on.

Parameters

string $name

Field to sort.

boolean $reverse

Reverse direction.

Returns

$this

sortFields()

sortFields(array  $fields) : $this

Sort on multiple fields.

Parameters

array $fields

Associative array where the keys are field names to sort on, and the values are the sort order: "asc" or "desc"

Returns

$this

term()

term() : $this

Term Query.

Matches documents that have fields that contain a term (not analyzed).

The term query maps to Lucene TermQuery.

Returns

$this

termClose()

termClose() : $this

Close a 'term' block.

Alias of close() for ease of reading in source.

Returns

$this

textPhrase()

textPhrase() : $this

Open a 'text_phrase' block.

Returns

$this

textPhraseClose()

textPhraseClose() : $this

Close a 'text_phrase' block.

Returns

$this

tieBreakerMultiplier()

tieBreakerMultiplier(float  $multiplier) : $this

When using dis_max, the disjunction max tie breaker.

Parameters

float $multiplier

Multiplier to use.

Returns

$this

wildcard()

wildcard() : $this

Query.

Returns

$this

wildcardClose()

wildcardClose() : $this

Close a 'wildcard' block.

Alias of close() for ease of reading in source.

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