PHP Class Elastica\Query

Creates different types of queries
Inheritance: extends Param
Afficher le fichier Open project: ruflin/elastica Class Usage Examples

Protected Properties

Свойство Type Description
$_suggest Suggest query or not.

Méthodes publiques

Méthode Description
__construct ( array | Elastica\Query\AbstractQuery $query = null ) Creates a query object.
addAggregation ( AbstractAggregation $agg ) Adds an Aggregation to the query.
addHighlight ( mixed $highlight ) Adds a highlight argument.
addScriptField ( string $name, Elastica\Script\AbstractScript $script ) Adds a Script to the query.
addSort ( mixed $sort ) Adds a sort param to the query.
create ( mixed $query ) : self Transforms a string or an array to a query object.
getQuery ( ) : Elastica\Query\AbstractQuery Gets the query object.
setExplain ( boolean $explain = true ) Enables explain on the query.
setFieldDataFields ( array $fieldDataFields ) Sets the fields not stored to be returned by the search.
setFrom ( integer $from ) Sets the start from which the search results should be returned.
setHighlight ( array $highlightArgs ) Sets highlight arguments for the query.
setMinScore ( float $minScore ) Allows filtering of documents based on a minimum score.
setPostFilter ( Elastica\Query\AbstractQuery $filter ) Sets post_filter argument for the query. The filter is applied after the query has executed.
setQuery ( Elastica\Query\AbstractQuery $query ) Sets the query.
setRawQuery ( array $query ) Sets query as raw array. Will overwrite all already set arguments.
setRescore ( mixed $rescore ) Add a Rescore.
setScriptFields ( array | ScriptFields $scriptFields ) Set script fields.
setSize ( integer $size = 10 ) Sets maximum number of results for this query.
setSort ( array $sortArgs ) Sets sort arguments for the query Replaces existing values.
setSource ( array | boolean $params ) Sets the _source field to be returned with every hit.
setStoredFields ( array $fields ) Sets the fields to be returned by the search NOTICE php will encode modified(or named keys) array into object format in json format request so the fields array must a sequence(list) type of array.
setSuggest ( Suggest $suggest ) Add a suggest term.
setTrackScores ( boolean $trackScores = true ) Keep track of the scores when sorting results.
setVersion ( boolean $version = true ) Enables version on the query.
toArray ( ) : array Converts all query params to an array.

Method Details

__construct() public méthode

Creates a query object.
public __construct ( array | Elastica\Query\AbstractQuery $query = null )
$query array | Elastica\Query\AbstractQuery OPTIONAL Query object (default = null)

addAggregation() public méthode

Adds an Aggregation to the query.
public addAggregation ( AbstractAggregation $agg )
$agg Elastica\Aggregation\AbstractAggregation

addHighlight() public méthode

Adds a highlight argument.
public addHighlight ( mixed $highlight )
$highlight mixed Add highlight argument

addScriptField() public méthode

Adds a Script to the query.
public addScriptField ( string $name, Elastica\Script\AbstractScript $script )
$name string
$script Elastica\Script\AbstractScript Script object

addSort() public méthode

Adds a sort param to the query.
public addSort ( mixed $sort )
$sort mixed Sort parameter

create() public static méthode

If query is empty,
public static create ( mixed $query ) : self
$query mixed
Résultat self

getQuery() public méthode

Gets the query object.
public getQuery ( ) : Elastica\Query\AbstractQuery
Résultat Elastica\Query\AbstractQuery

setExplain() public méthode

Enables explain on the query.
public setExplain ( boolean $explain = true )
$explain boolean OPTIONAL Enabled or disable explain (default = true)

setFieldDataFields() public méthode

Sets the fields not stored to be returned by the search.
public setFieldDataFields ( array $fieldDataFields )
$fieldDataFields array Fields not stored to be returned

setFrom() public méthode

Sets the start from which the search results should be returned.
public setFrom ( integer $from )
$from integer

setHighlight() public méthode

Sets highlight arguments for the query.
public setHighlight ( array $highlightArgs )
$highlightArgs array Set all highlight arguments

setMinScore() public méthode

Allows filtering of documents based on a minimum score.
public setMinScore ( float $minScore )
$minScore float Minimum score to filter documents by

setPostFilter() public méthode

Sets post_filter argument for the query. The filter is applied after the query has executed.
public setPostFilter ( Elastica\Query\AbstractQuery $filter )
$filter Elastica\Query\AbstractQuery

setQuery() public méthode

Sets the query.
public setQuery ( Elastica\Query\AbstractQuery $query )
$query Elastica\Query\AbstractQuery Query object

setRawQuery() public méthode

Sets query as raw array. Will overwrite all already set arguments.
public setRawQuery ( array $query )
$query array Query array

setRescore() public méthode

Add a Rescore.
public setRescore ( mixed $rescore )
$rescore mixed suggestion object

setScriptFields() public méthode

Set script fields.
public setScriptFields ( array | ScriptFields $scriptFields )
$scriptFields array | Elastica\Script\ScriptFields Script fields

setSize() public méthode

Sets maximum number of results for this query.
public setSize ( integer $size = 10 )
$size integer OPTIONAL Maximal number of results for query (default = 10)

setSort() public méthode

Sets sort arguments for the query Replaces existing values.
public setSort ( array $sortArgs )
$sortArgs array Sorting arguments

setSource() public méthode

Sets the _source field to be returned with every hit.
public setSource ( array | boolean $params )
$params array | boolean Fields to be returned or false to disable source

setStoredFields() public méthode

Sets the fields to be returned by the search NOTICE php will encode modified(or named keys) array into object format in json format request so the fields array must a sequence(list) type of array.
public setStoredFields ( array $fields )
$fields array Fields to be returned

setSuggest() public méthode

Add a suggest term.
public setSuggest ( Suggest $suggest )
$suggest Suggest suggestion object

setTrackScores() public méthode

Keep track of the scores when sorting results.
public setTrackScores ( boolean $trackScores = true )
$trackScores boolean

setVersion() public méthode

Enables version on the query.
public setVersion ( boolean $version = true )
$version boolean OPTIONAL Enabled or disable version (default = true)

toArray() public méthode

Converts all query params to an array.
public toArray ( ) : array
Résultat array Query array

Property Details

$_suggest protected_oe property

Suggest query or not.
protected $_suggest