include/SugarSearchEngine/Elastic/Elastica/Query/Builder.php
Query Builder.
- Author
- Chris Gedrim
- Category
- Xodoa
- Link
- http://www.elasticsearch.com/
- Package
- Elastica
- Uses
- \Elastica_Query_Abstract
\Elastica_Query_Builder
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

array
$_params= 'array()'
array()Details- Type
- array
- Inherited_from
- \Elastica_Param::$$_params
- Inherited_from
- \Elastica_Query_Abstract::$$_params

$_rawParams= 'array()'
array()Details- Type
- n/a
- Inherited_from
- \Elastica_Param::$$_rawParams
- Inherited_from
- \Elastica_Query_Abstract::$$_rawParams
Methods

__construct(
string $string
=
null
)
:
voidConstructor
| Name | Type | Description |
|---|---|---|
| $string | string | JSON encoded string to use as query. |

_setRawParam(
string $key, mixed $value
)
:
\Elastica_ParamSets params not inside params array
Inherited from: \Elastica_Param::_setRawParam()\Elastica_Query_Abstract::_setRawParam()| Name | Type | Description |
|---|---|---|
| $key | string | |
| $value | mixed |
| Type | Description |
|---|---|
| \Elastica_Param |

addParam(
string $key, mixed $value
)
:
\Elastica_ParamAdds 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
| Name | Type | Description |
|---|---|---|
| $key | string | Param key |
| $value | mixed | Value to set |
| Type | Description |
|---|---|
| \Elastica_Param |

allowLeadingWildcard(
boolean $bool
=
true
)
:
\Elastica_Query_BuilderAllow widcards (*, ?) as the first character in a query.
| Name | Type | Description |
|---|---|---|
| $bool | boolean | Defaults to true. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

analyzeWildcard(
boolean $bool
=
true
)
:
\Elastica_Query_BuilderEnable best effort analysis of wildcard terms.
| Name | Type | Description |
|---|---|---|
| $bool | boolean | Defaults to true. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

analyzer(
string $analyzer
)
:
\Elastica_Query_BuilderSet the analyzer name used to analyze the query string.
| Name | Type | Description |
|---|---|---|
| $analyzer | string | Analyzer to use. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

autoGeneratePhraseQueries(
boolean $bool
=
true
)
:
\Elastica_Query_BuilderAuitogenerate phrase queries.
| Name | Type | Description |
|---|---|---|
| $bool | boolean | Defaults to true. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

bool(
)
:
\Elastica_Query_BuilderBool 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.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

boolClose(
)
:
\Elastica_Query_BuilderClose a 'bool' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

boost(
float $boost
=
1.0
)
:
\Elastica_Query_BuilderSets the boost value of the query.
| Name | Type | Description |
|---|---|---|
| $boost | float | Defaults to 1.0. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

close(
)
:
\Elastica_Query_BuilderClose a previously opened brace.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

constantScore(
)
:
\Elastica_Query_BuilderConstant 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.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

constantScoreClose(
)
:
\Elastica_Query_BuilderClose a 'constant_score' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

defaultField(
string $field
=
'_all'
)
:
\Elastica_Query_BuilderThe default field for query terms if no prefix field is specified.
| Name | Type | Description |
|---|---|---|
| $field | string | Defaults to _all. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

defaultOperator(
string $operator
=
'OR'
)
:
\Elastica_Query_BuilderThe 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".
| Name | Type | Description |
|---|---|---|
| $operator | string | Defaults to OR. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

disMax(
)
:
\Elastica_Query_BuilderDis 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.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

disMaxClose(
)
:
\Elastica_Query_BuilderClose a 'dis_max' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

enablePositionIncrements(
boolean $bool
=
true
)
:
\Elastica_Query_BuilderEnable position increments in result queries.
| Name | Type | Description |
|---|---|---|
| $bool | boolean | Defaults to true. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

explain(
boolean $value
=
true
)
:
\Elastica_Query_BuilderEnables explanation for each hit on how its score was computed.
| Name | Type | Description |
|---|---|---|
| $value | boolean | Turn on / off explain. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

facets(
)
:
\Elastica_Query_BuilderOpen '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.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

facetsClose(
)
:
\Elastica_Query_BuilderClose a facets block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

factory(
string $string
=
null
)
:
\Elastica_Query_BuilderFactory method.
| Name | Type | Description |
|---|---|---|
| $string | string | JSON encoded string to use as query. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

field(
string $name, mixed $value
)
:
\Elastica_Query_BuilderAdd a specific field / value entry.
| Name | Type | Description |
|---|---|---|
| $name | string | Field to add. |
| $value | mixed | Value to set. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

fieldClose(
)
:
\Elastica_Query_BuilderClose 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();
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

fieldOpen(
string $name
)
:
\Elastica_Query_BuilderOpen a node for the specified name.
| Name | Type | Description |
|---|---|---|
| $name | string | Field name. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

fields(
array $fields
)
:
\Elastica_Query_BuilderExplicitly define fields to return.
| Name | Type | Description |
|---|---|---|
| $fields | array | Array of fields to return. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

filter(
)
:
\Elastica_Query_BuilderOpen a 'filter' block.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

filterClose(
)
:
\Elastica_Query_BuilderClose a filter block.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

filteredQueryClose(
)
:
\Elastica_Query_BuilderClose a 'filtered_query' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

from(
integer $value
=
0
)
:
\Elastica_Query_BuilderSet the from parameter (offset).
| Name | Type | Description |
|---|---|---|
| $value | integer | Result number to start from. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

fuzzyMinSim(
float $value
=
0.5
)
:
\Elastica_Query_BuilderSet the minimum similarity for fuzzy queries.
| Name | Type | Description |
|---|---|---|
| $value | float | Defaults to 0.5. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

fuzzyPrefixLength(
integer $value
=
0
)
:
\Elastica_Query_BuilderSet the prefix length for fuzzy queries.
| Name | Type | Description |
|---|---|---|
| $value | integer | Defaults to 0. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

getParam(
string $key
)
:
mixedReturns a specific param
Inherited from: \Elastica_Param::getParam()\Elastica_Query_Abstract::getParam()| Name | Type | Description |
|---|---|---|
| $key | string | Key to return |
| Type | Description |
|---|---|
| mixed | Key value |
| Exception | Description |
|---|---|
| \Elastica_Exception_Invalid | If requested key is not set |

getParams(
)
:
arrayReturns the params array
Inherited from: \Elastica_Param::getParams()\Elastica_Query_Abstract::getParams()| Type | Description |
|---|---|
| array | Params |

gt(
mixed $value
)
:
\Elastica_Query_BuilderAdd a greater than (gt) clause.
Used in range blocks.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Value to be gt. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

gte(
mixed $value
)
:
\Elastica_Query_BuilderAdd a greater than or equal to (lt) clause.
Used in range blocks.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Value to be gte to. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

lowercaseExpandedTerms(
boolean $bool
=
true
)
:
\Elastica_Query_BuilderAutomatically lower-case terms of wildcard, prefix, fuzzy, and range queries.
| Name | Type | Description |
|---|---|---|
| $bool | boolean | Defaults to true. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

lt(
mixed $value
)
:
\Elastica_Query_BuilderAdd a less than (lt) clause.
Used in range blocks.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Value to be lt. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

lte(
mixed $value
)
:
\Elastica_Query_BuilderAdd a less than or equal to (lte) clause.
Used in range blocks.
| Name | Type | Description |
|---|---|---|
| $value | mixed | Value to be lte to. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

matchAll(
float $boost
=
null
)
:
\Elastica_Query_BuilderMatch All Query.
A query that matches all documents.
Maps to Lucene MatchAllDocsQuery.
| Name | Type | Description |
|---|---|---|
| $boost | float | Boost to use. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

minimumShouldMatch(
integer $minimum
)
:
\Elastica_Query_BuilderThe minimum number of should clauses to match.
| Name | Type | Description |
|---|---|---|
| $minimum | integer | Minimum number that should match. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

must(
)
:
\Elastica_Query_BuilderThe clause (query) must appear in matching documents.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

mustClose(
)
:
\Elastica_Query_BuilderClose a 'must' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

mustNot(
)
:
\Elastica_Query_BuilderThe 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.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

mustNotClose(
)
:
\Elastica_Query_BuilderClose a 'must_not' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

open(
)
:
\Elastica_Query_BuilderAdd an opening brace.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

phraseSlop(
integer $value
=
0
)
:
\Elastica_Query_BuilderSets the default slop for phrases.
If zero, then exact phrase matches are required.
| Name | Type | Description |
|---|---|---|
| $value | integer | Defaults to 0. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

prefixClose(
)
:
\Elastica_Query_BuilderClose a 'prefix' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

queries(
array $queries
)
:
\Elastica_Query_BuilderQueries to run within a dis_max query.
| Name | Type | Description |
|---|---|---|
| $queries | array | Array of queries. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

query(
)
:
\Elastica_Query_BuilderOpen a query block.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

queryClose(
)
:
\Elastica_Query_BuilderClose a query block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

queryString(
)
:
\Elastica_Query_BuilderQuery String Query.
A query that uses a query parser in order to parse its content
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

queryStringClose(
)
:
\Elastica_Query_BuilderClose a 'query_string' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

range(
)
:
\Elastica_Query_BuilderOpen a range block.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

rangeClose(
)
:
\Elastica_Query_BuilderClose a range block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

setParam(
string $key, mixed $value
)
:
voidSets (overwrites) the value at the given key
Inherited from: \Elastica_Param::setParam()\Elastica_Query_Abstract::setParam()| Name | Type | Description |
|---|---|---|
| $key | string | Key to set |
| $value | mixed | Key Value |

setParams(
array $params
)
:
\Elastica_ParamSets (overwrites) all params of this object
Inherited from: \Elastica_Param::setParams()\Elastica_Query_Abstract::setParams()| Name | Type | Description |
|---|---|---|
| $params | array | Parameter list |
| Type | Description |
|---|---|
| \Elastica_Param |

should(
)
:
\Elastica_Query_BuilderThe clause (query) should appear in the matching document.
A boolean query with no must clauses, one or more should clauses must match a document.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

shouldClose(
)
:
\Elastica_Query_BuilderClose a 'should' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

size(
integer $value
=
10
)
:
\Elastica_Query_BuilderSet the size parameter (number of records to return).
| Name | Type | Description |
|---|---|---|
| $value | integer | Number of records to return. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

sort(
)
:
\Elastica_Query_BuilderAllows to add one or more sort on specific fields.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

sortClose(
)
:
\Elastica_Query_BuilderClose a sort block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

sortField(
string $name, boolean $reverse
=
false
)
:
\Elastica_Query_BuilderAdd a field to sort on.
| Name | Type | Description |
|---|---|---|
| $name | string | Field to sort. |
| $reverse | boolean | Reverse direction. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

term(
)
:
\Elastica_Query_BuilderTerm Query.
Matches documents that have fields that contain a term (not analyzed).
The term query maps to Lucene TermQuery.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

termClose(
)
:
\Elastica_Query_BuilderClose a 'term' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

textPhrase(
)
:
\Elastica_Query_BuilderOpen a 'text_phrase' block.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

textPhraseClose(
)
:
\Elastica_Query_BuilderClose a 'text_phrase' block.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

tieBreaker(
float $multiplier
)
:
\Elastica_Query_BuilderWhen using dis_max, the disjunction max tie breaker.
| Name | Type | Description |
|---|---|---|
| $multiplier | float | Multiplier to use. |
| Type | Description |
|---|---|
| \Elastica_Query_Builder |

toArray(
)
:
arrayConverts 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
| Type | Description |
|---|---|
| array | Filter array |

wildcardClose(
)
:
\Elastica_Query_BuilderClose a 'wildcard' block.
Alias of close() for ease of reading in source.
| Type | Description |
|---|---|
| \Elastica_Query_Builder |