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
)
:
void
Constructor
Name | Type | Description |
---|---|---|
$string | string | JSON encoded string to use as query. |
_setRawParam(
string $key, mixed $value
)
:
\Elastica_Param
Sets 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_Param
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
Name | Type | Description |
---|---|---|
$key | string | Param key |
$value | mixed | Value to set |
Type | Description |
---|---|
\Elastica_Param |
allowLeadingWildcard(
boolean $bool
=
true
)
:
\Elastica_Query_Builder
Allow 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_Builder
Enable best effort analysis of wildcard terms.
Name | Type | Description |
---|---|---|
$bool | boolean | Defaults to true. |
Type | Description |
---|---|
\Elastica_Query_Builder |
analyzer(
string $analyzer
)
:
\Elastica_Query_Builder
Set 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_Builder
Auitogenerate phrase queries.
Name | Type | Description |
---|---|---|
$bool | boolean | Defaults to true. |
Type | Description |
---|---|
\Elastica_Query_Builder |
bool(
)
:
\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.
Type | Description |
---|---|
\Elastica_Query_Builder |
boolClose(
)
:
\Elastica_Query_Builder
Close a 'bool' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
boost(
float $boost
=
1.0
)
:
\Elastica_Query_Builder
Sets the boost value of the query.
Name | Type | Description |
---|---|---|
$boost | float | Defaults to 1.0. |
Type | Description |
---|---|
\Elastica_Query_Builder |
close(
)
:
\Elastica_Query_Builder
Close a previously opened brace.
Type | Description |
---|---|
\Elastica_Query_Builder |
constantScore(
)
:
\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.
Type | Description |
---|---|
\Elastica_Query_Builder |
constantScoreClose(
)
:
\Elastica_Query_Builder
Close a 'constant_score' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
defaultField(
string $field
=
'_all'
)
:
\Elastica_Query_Builder
The 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_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".
Name | Type | Description |
---|---|---|
$operator | string | Defaults to OR. |
Type | Description |
---|---|
\Elastica_Query_Builder |
disMax(
)
:
\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.
Type | Description |
---|---|
\Elastica_Query_Builder |
disMaxClose(
)
:
\Elastica_Query_Builder
Close a 'dis_max' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
enablePositionIncrements(
boolean $bool
=
true
)
:
\Elastica_Query_Builder
Enable position increments in result queries.
Name | Type | Description |
---|---|---|
$bool | boolean | Defaults to true. |
Type | Description |
---|---|
\Elastica_Query_Builder |
explain(
boolean $value
=
true
)
:
\Elastica_Query_Builder
Enables 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_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.
Type | Description |
---|---|
\Elastica_Query_Builder |
facetsClose(
)
:
\Elastica_Query_Builder
Close a facets block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
factory(
string $string
=
null
)
:
\Elastica_Query_Builder
Factory 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_Builder
Add 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_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();
Type | Description |
---|---|
\Elastica_Query_Builder |
fieldOpen(
string $name
)
:
\Elastica_Query_Builder
Open a node for the specified name.
Name | Type | Description |
---|---|---|
$name | string | Field name. |
Type | Description |
---|---|
\Elastica_Query_Builder |
fields(
array $fields
)
:
\Elastica_Query_Builder
Explicitly define fields to return.
Name | Type | Description |
---|---|---|
$fields | array | Array of fields to return. |
Type | Description |
---|---|
\Elastica_Query_Builder |
filter(
)
:
\Elastica_Query_Builder
Open a 'filter' block.
Type | Description |
---|---|
\Elastica_Query_Builder |
filterClose(
)
:
\Elastica_Query_Builder
Close a filter block.
Type | Description |
---|---|
\Elastica_Query_Builder |
filteredQueryClose(
)
:
\Elastica_Query_Builder
Close a 'filtered_query' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
from(
integer $value
=
0
)
:
\Elastica_Query_Builder
Set 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_Builder
Set 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_Builder
Set the prefix length for fuzzy queries.
Name | Type | Description |
---|---|---|
$value | integer | Defaults to 0. |
Type | Description |
---|---|
\Elastica_Query_Builder |
getParam(
string $key
)
:
mixed
Returns 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(
)
:
array
Returns the params array
Inherited from: \Elastica_Param::getParams()\Elastica_Query_Abstract::getParams()Type | Description |
---|---|
array | Params |
gt(
mixed $value
)
:
\Elastica_Query_Builder
Add 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_Builder
Add 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_Builder
Automatically 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_Builder
Add 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_Builder
Add 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_Builder
Match 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_Builder
The 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_Builder
The clause (query) must appear in matching documents.
Type | Description |
---|---|
\Elastica_Query_Builder |
mustClose(
)
:
\Elastica_Query_Builder
Close a 'must' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
mustNot(
)
:
\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.
Type | Description |
---|---|
\Elastica_Query_Builder |
mustNotClose(
)
:
\Elastica_Query_Builder
Close a 'must_not' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
open(
)
:
\Elastica_Query_Builder
Add an opening brace.
Type | Description |
---|---|
\Elastica_Query_Builder |
phraseSlop(
integer $value
=
0
)
:
\Elastica_Query_Builder
Sets 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_Builder
Close a 'prefix' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
queries(
array $queries
)
:
\Elastica_Query_Builder
Queries to run within a dis_max query.
Name | Type | Description |
---|---|---|
$queries | array | Array of queries. |
Type | Description |
---|---|
\Elastica_Query_Builder |
query(
)
:
\Elastica_Query_Builder
Open a query block.
Type | Description |
---|---|
\Elastica_Query_Builder |
queryClose(
)
:
\Elastica_Query_Builder
Close a query block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
queryString(
)
:
\Elastica_Query_Builder
Query String Query.
A query that uses a query parser in order to parse its content
Type | Description |
---|---|
\Elastica_Query_Builder |
queryStringClose(
)
:
\Elastica_Query_Builder
Close a 'query_string' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
range(
)
:
\Elastica_Query_Builder
Open a range block.
Type | Description |
---|---|
\Elastica_Query_Builder |
rangeClose(
)
:
\Elastica_Query_Builder
Close a range block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
setParam(
string $key, mixed $value
)
:
void
Sets (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_Param
Sets (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_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.
Type | Description |
---|---|
\Elastica_Query_Builder |
shouldClose(
)
:
\Elastica_Query_Builder
Close a 'should' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
size(
integer $value
=
10
)
:
\Elastica_Query_Builder
Set 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_Builder
Allows to add one or more sort on specific fields.
Type | Description |
---|---|
\Elastica_Query_Builder |
sortClose(
)
:
\Elastica_Query_Builder
Close 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_Builder
Add 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_Builder
Term 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_Builder
Close a 'term' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |
textPhrase(
)
:
\Elastica_Query_Builder
Open a 'text_phrase' block.
Type | Description |
---|---|
\Elastica_Query_Builder |
textPhraseClose(
)
:
\Elastica_Query_Builder
Close a 'text_phrase' block.
Type | Description |
---|---|
\Elastica_Query_Builder |
tieBreaker(
float $multiplier
)
:
\Elastica_Query_Builder
When using dis_max, the disjunction max tie breaker.
Name | Type | Description |
---|---|---|
$multiplier | float | Multiplier to use. |
Type | Description |
---|---|
\Elastica_Query_Builder |
toArray(
)
:
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
Type | Description |
---|---|
array | Filter array |
wildcardClose(
)
:
\Elastica_Query_Builder
Close a 'wildcard' block.
Alias of close() for ease of reading in source.
Type | Description |
---|---|
\Elastica_Query_Builder |