include/SugarSearchEngine/Elastic/Elastica/Query/Builder.php

Show: inherited
Table of Contents

Query Builder.

Author
Chris Gedrim  
Category
Xodoa  
Link
http://www.elasticsearch.com/  
Package
Elastica  
Uses
\Elastica_Query_Abstract  

\Elastica_Query_Builder

Package: Elastica

Query Builder.

This function can be used to handle params for queries, filter, facets

Parent(s)
\Elastica_Query_Abstract < \Elastica_Param
Author
Chris Gedrim  
Category
Xodoa  
Link
http://www.elasticsearch.com/  
Uses
\Elastica_Query_Abstract  

Properties

Propertyprotectedarray  $_params= 'array()'
Default valuearray()Details
Type
array
Inherited_from
\Elastica_Param::$$_params  
Inherited_from
\Elastica_Query_Abstract::$$_params  
Propertyprotected  $_rawParams= 'array()'
Default valuearray()Details
Type
n/a
Inherited_from
\Elastica_Param::$$_rawParams  
Inherited_from
\Elastica_Query_Abstract::$$_rawParams  
Propertyprivatestring  $_string= ''{''

Query string.

Default value'{'Details
Type
string

Methods

methodpublic__construct( string $string = null ) : void

Constructor

Parameters
Name Type Description
$string string

JSON encoded string to use as query.

methodpublic__toString( ) : string

Output the query string.

Returns
Type Description
string
methodprotected_setRawParam( string $key, mixed $value ) : \Elastica_Param
inherited

Sets params not inside params array

Inherited from: \Elastica_Param::_setRawParam()\Elastica_Query_Abstract::_setRawParam()
Parameters
Name Type Description
$key string
$value mixed
Returns
Type Description
\Elastica_Param
methodpublicaddParam( string $key, mixed $value ) : \Elastica_Param
inherited

Adds a param to the list

Inherited from: \Elastica_Param::addParam()\Elastica_Query_Abstract::addParam()

This function can be used to add an array of params

Parameters
Name Type Description
$key string

Param key

$value mixed

Value to set

Returns
Type Description
\Elastica_Param
methodpublicallowLeadingWildcard( boolean $bool = true ) : \Elastica_Query_Builder

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

Parameters
Name Type Description
$bool boolean

Defaults to true.

Returns
Type Description
\Elastica_Query_Builder
methodpublicanalyzeWildcard( boolean $bool = true ) : \Elastica_Query_Builder

Enable best effort analysis of wildcard terms.

Parameters
Name Type Description
$bool boolean

Defaults to true.

Returns
Type Description
\Elastica_Query_Builder
methodpublicanalyzer( string $analyzer ) : \Elastica_Query_Builder

Set the analyzer name used to analyze the query string.

Parameters
Name Type Description
$analyzer string

Analyzer to use.

Returns
Type Description
\Elastica_Query_Builder
methodpublicautoGeneratePhraseQueries( boolean $bool = true ) : \Elastica_Query_Builder

Auitogenerate phrase queries.

Parameters
Name Type Description
$bool boolean

Defaults to true.

Returns
Type Description
\Elastica_Query_Builder
methodpublicbool( ) : \Elastica_Query_Builder

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
Type Description
\Elastica_Query_Builder
methodpublicboolClose( ) : \Elastica_Query_Builder

Close a 'bool' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicboost( float $boost = 1.0 ) : \Elastica_Query_Builder

Sets the boost value of the query.

Parameters
Name Type Description
$boost float

Defaults to 1.0.

Returns
Type Description
\Elastica_Query_Builder
methodpublicclose( ) : \Elastica_Query_Builder

Close a previously opened brace.

Returns
Type Description
\Elastica_Query_Builder
methodpublicconstantScore( ) : \Elastica_Query_Builder

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
Type Description
\Elastica_Query_Builder
methodpublicconstantScoreClose( ) : \Elastica_Query_Builder

Close a 'constant_score' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicdefaultField( string $field = '_all' ) : \Elastica_Query_Builder

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

Parameters
Name Type Description
$field string

Defaults to _all.

Returns
Type Description
\Elastica_Query_Builder
methodpublicdefaultOperator( string $operator = 'OR' ) : \Elastica_Query_Builder

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
Name Type Description
$operator string

Defaults to OR.

Returns
Type Description
\Elastica_Query_Builder
methodpublicdisMax( ) : \Elastica_Query_Builder

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
Type Description
\Elastica_Query_Builder
methodpublicdisMaxClose( ) : \Elastica_Query_Builder

Close a 'dis_max' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicenablePositionIncrements( boolean $bool = true ) : \Elastica_Query_Builder

Enable position increments in result queries.

Parameters
Name Type Description
$bool boolean

Defaults to true.

Returns
Type Description
\Elastica_Query_Builder
methodpublicexplain( boolean $value = true ) : \Elastica_Query_Builder

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

Parameters
Name Type Description
$value boolean

Turn on / off explain.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfacets( ) : \Elastica_Query_Builder

Open 'facets' block.

Facets provide aggregated data based on a search query.

In the simple case, a facet can return facet counts for various facet values for a specific field.

ElasticSearch supports more advanced facet implementations, such as statistical or date histogram facets.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfacetsClose( ) : \Elastica_Query_Builder

Close a facets block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicfactory( string $string = null ) : \Elastica_Query_Builder
static

Factory method.

Parameters
Name Type Description
$string string

JSON encoded string to use as query.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfield( string $name, mixed $value ) : \Elastica_Query_Builder

Add a specific field / value entry.

Parameters
Name Type Description
$name string

Field to add.

$value mixed

Value to set.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfieldClose( ) : \Elastica_Query_Builder

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.

Elastica_Query_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
Type Description
\Elastica_Query_Builder
methodpublicfieldOpen( string $name ) : \Elastica_Query_Builder

Open a node for the specified name.

Parameters
Name Type Description
$name string

Field name.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfields( array $fields ) : \Elastica_Query_Builder

Explicitly define fields to return.

Parameters
Name Type Description
$fields array

Array of fields to return.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfilter( ) : \Elastica_Query_Builder

Open a 'filter' block.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfilterClose( ) : \Elastica_Query_Builder

Close a filter block.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfilteredQuery( ) : \Elastica_Query_Builder

Query.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfilteredQueryClose( ) : \Elastica_Query_Builder

Close a 'filtered_query' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicfrom( integer $value = 0 ) : \Elastica_Query_Builder

Set the from parameter (offset).

Parameters
Name Type Description
$value integer

Result number to start from.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfuzzyMinSim( float $value = 0.5 ) : \Elastica_Query_Builder

Set the minimum similarity for fuzzy queries.

Parameters
Name Type Description
$value float

Defaults to 0.5.

Returns
Type Description
\Elastica_Query_Builder
methodpublicfuzzyPrefixLength( integer $value = 0 ) : \Elastica_Query_Builder

Set the prefix length for fuzzy queries.

Parameters
Name Type Description
$value integer

Defaults to 0.

Returns
Type Description
\Elastica_Query_Builder
methodpublicgetParam( string $key ) : mixed
inherited

Returns a specific param

Inherited from: \Elastica_Param::getParam()\Elastica_Query_Abstract::getParam()
Parameters
Name Type Description
$key string

Key to return

Returns
Type Description
mixed Key value
Throws
Exception Description
\Elastica_Exception_Invalid If requested key is not set
methodpublicgetParams( ) : array
inherited

Returns the params array

Inherited from: \Elastica_Param::getParams()\Elastica_Query_Abstract::getParams()
Returns
Type Description
array Params
methodpublicgt( mixed $value ) : \Elastica_Query_Builder

Add a greater than (gt) clause.

Used in range blocks.

Parameters
Name Type Description
$value mixed

Value to be gt.

Returns
Type Description
\Elastica_Query_Builder
methodpublicgte( mixed $value ) : \Elastica_Query_Builder

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

Used in range blocks.

Parameters
Name Type Description
$value mixed

Value to be gte to.

Returns
Type Description
\Elastica_Query_Builder
methodpubliclowercaseExpandedTerms( boolean $bool = true ) : \Elastica_Query_Builder

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

Parameters
Name Type Description
$bool boolean

Defaults to true.

Returns
Type Description
\Elastica_Query_Builder
methodpubliclt( mixed $value ) : \Elastica_Query_Builder

Add a less than (lt) clause.

Used in range blocks.

Parameters
Name Type Description
$value mixed

Value to be lt.

Returns
Type Description
\Elastica_Query_Builder
methodpubliclte( mixed $value ) : \Elastica_Query_Builder

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

Used in range blocks.

Parameters
Name Type Description
$value mixed

Value to be lte to.

Returns
Type Description
\Elastica_Query_Builder
methodpublicmatchAll( float $boost = null ) : \Elastica_Query_Builder

Match All Query.

A query that matches all documents.

Maps to Lucene MatchAllDocsQuery.

Parameters
Name Type Description
$boost float

Boost to use.

Returns
Type Description
\Elastica_Query_Builder
methodpublicminimumShouldMatch( integer $minimum ) : \Elastica_Query_Builder

The minimum number of should clauses to match.

Parameters
Name Type Description
$minimum integer

Minimum number that should match.

Returns
Type Description
\Elastica_Query_Builder
methodpublicmust( ) : \Elastica_Query_Builder

The clause (query) must appear in matching documents.

Returns
Type Description
\Elastica_Query_Builder
methodpublicmustClose( ) : \Elastica_Query_Builder

Close a 'must' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicmustNot( ) : \Elastica_Query_Builder

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
Type Description
\Elastica_Query_Builder
methodpublicmustNotClose( ) : \Elastica_Query_Builder

Close a 'must_not' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicopen( ) : \Elastica_Query_Builder

Add an opening brace.

Returns
Type Description
\Elastica_Query_Builder
methodpublicphraseSlop( integer $value = 0 ) : \Elastica_Query_Builder

Sets the default slop for phrases.

If zero, then exact phrase matches are required.

Parameters
Name Type Description
$value integer

Defaults to 0.

Returns
Type Description
\Elastica_Query_Builder
methodpublicprefix( ) : \Elastica_Query_Builder

Query.

Returns
Type Description
\Elastica_Query_Builder
methodpublicprefixClose( ) : \Elastica_Query_Builder

Close a 'prefix' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicqueries( array $queries ) : \Elastica_Query_Builder

Queries to run within a dis_max query.

Parameters
Name Type Description
$queries array

Array of queries.

Returns
Type Description
\Elastica_Query_Builder
methodpublicquery( ) : \Elastica_Query_Builder

Open a query block.

Returns
Type Description
\Elastica_Query_Builder
methodpublicqueryClose( ) : \Elastica_Query_Builder

Close a query block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicqueryString( ) : \Elastica_Query_Builder

Query String Query.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicqueryStringClose( ) : \Elastica_Query_Builder

Close a 'query_string' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicrange( ) : \Elastica_Query_Builder

Open a range block.

Returns
Type Description
\Elastica_Query_Builder
methodpublicrangeClose( ) : \Elastica_Query_Builder

Close a range block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicsetParam( string $key, mixed $value ) : void
inherited

Sets (overwrites) the value at the given key

Inherited from: \Elastica_Param::setParam()\Elastica_Query_Abstract::setParam()
Parameters
Name Type Description
$key string

Key to set

$value mixed

Key Value

methodpublicsetParams( array $params ) : \Elastica_Param
inherited

Sets (overwrites) all params of this object

Inherited from: \Elastica_Param::setParams()\Elastica_Query_Abstract::setParams()
Parameters
Name Type Description
$params array

Parameter list

Returns
Type Description
\Elastica_Param
methodpublicshould( ) : \Elastica_Query_Builder

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
Type Description
\Elastica_Query_Builder
methodpublicshouldClose( ) : \Elastica_Query_Builder

Close a 'should' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicsize( integer $value = 10 ) : \Elastica_Query_Builder

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

Parameters
Name Type Description
$value integer

Number of records to return.

Returns
Type Description
\Elastica_Query_Builder
methodpublicsort( ) : \Elastica_Query_Builder

Allows to add one or more sort on specific fields.

Returns
Type Description
\Elastica_Query_Builder
methodpublicsortClose( ) : \Elastica_Query_Builder

Close a sort block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublicsortField( string $name, boolean $reverse = false ) : \Elastica_Query_Builder

Add a field to sort on.

Parameters
Name Type Description
$name string

Field to sort.

$reverse boolean

Reverse direction.

Returns
Type Description
\Elastica_Query_Builder
methodpublicterm( ) : \Elastica_Query_Builder

Term Query.

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

The term query maps to Lucene TermQuery.

Returns
Type Description
\Elastica_Query_Builder
methodpublictermClose( ) : \Elastica_Query_Builder

Close a 'term' block.

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

Returns
Type Description
\Elastica_Query_Builder
methodpublictextPhrase( ) : \Elastica_Query_Builder

Open a 'text_phrase' block.

Returns
Type Description
\Elastica_Query_Builder
methodpublictextPhraseClose( ) : \Elastica_Query_Builder

Close a 'text_phrase' block.

Returns
Type Description
\Elastica_Query_Builder
methodpublictieBreaker( float $multiplier ) : \Elastica_Query_Builder

When using dis_max, the disjunction max tie breaker.

Parameters
Name Type Description
$multiplier float

Multiplier to use.

Returns
Type Description
\Elastica_Query_Builder
methodpublictoArray( ) : 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
Type Description
array Filter array
methodpublicwildcard( ) : \Elastica_Query_Builder

Query.

Returns
Type Description
\Elastica_Query_Builder
methodpublicwildcardClose( ) : \Elastica_Query_Builder

Close a 'wildcard' block.

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

Returns
Type Description
\Elastica_Query_Builder
Documentation was generated by DocBlox 0.18.1.