Skip to content

Commit

Permalink
Update query builder query dsl
Browse files Browse the repository at this point in the history
  • Loading branch information
deguif committed Nov 18, 2019
1 parent e62898f commit 6039365
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 15 deletions.
68 changes: 56 additions & 12 deletions lib/Elastica/QueryBuilder/DSL/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
use Elastica\Query\Exists;
use Elastica\Query\FunctionScore;
use Elastica\Query\Fuzzy;
use Elastica\Query\GeoBoundingBox;
use Elastica\Query\GeoDistance;
use Elastica\Query\GeoPolygon;
use Elastica\Query\HasChild;
use Elastica\Query\HasParent;
use Elastica\Query\Ids;
use Elastica\Query\Match;
use Elastica\Query\MatchAll;
use Elastica\Query\MatchNone;
use Elastica\Query\MatchPhrase;
use Elastica\Query\MatchPhrasePrefix;
use Elastica\Query\MoreLikeThis;
use Elastica\Query\MultiMatch;
use Elastica\Query\Nested;
Expand Down Expand Up @@ -159,6 +163,38 @@ public function fuzzy(string $fieldName = null, string $value = null): Fuzzy
return new Fuzzy($fieldName, $value);
}

/**
* geo bounding box query.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html
*/
public function geo_bounding_box(string $key, array $coordinates): GeoBoundingBox
{
return new GeoBoundingBox($key, $coordinates);
}

/**
* geo distance query.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
*
* @param array|string $location
*/
public function geo_distance(string $key, $location, string $distance): GeoDistance
{
return new GeoDistance($key, $location, $distance);
}

/**
* geo polygon query.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html
*/
public function geo_polygon(string $key, array $points): GeoPolygon
{
return new GeoPolygon($key, $points);
}

/**
* geo shape query.
*
Expand Down Expand Up @@ -225,6 +261,26 @@ public function match_none(): MatchNone
return new MatchNone();
}

/**
* match phrase query.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html
*/
public function match_phrase(string $field = null, $values = null): MatchPhrase
{
return new MatchPhrase($field, $values);
}

/**
* match phrase prefix query.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html
*/
public function match_phrase_prefix(string $field = null, $values = null): MatchPhrasePrefix
{
return new MatchPhrasePrefix($field, $values);
}

/**
* more like this query.
*
Expand Down Expand Up @@ -432,18 +488,6 @@ public function wildcard(string $key = '', string $value = null, float $boost =
return new Wildcard($key, $value, $boost);
}

/**
* geo distance query.
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
*
* @param array|string $location
*/
public function geo_distance(string $key, $location, string $distance): GeoDistance
{
return new GeoDistance($key, $location, $distance);
}

/**
* exists query.
*
Expand Down
11 changes: 8 additions & 3 deletions lib/Elastica/QueryBuilder/Version/Version700.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,27 @@
class Version700 extends Version
{
protected $queries = [
'match',
'multi_match',
'bool',
'boosting',
'common_terms',
'constant_score',
'dis_max',
'function_score',
'fuzzy',
'geo_bounding_box',
'geo_distance',
'geo_polygon',
'geo_shape',
'has_child',
'has_parent',
'ids',
'match',
'match_all',
'match_none',
'match_phrase',
'match_phrase_prefix',
'more_like_this',
'multi_match',
'nested',
'parent_id',
'prefix',
Expand All @@ -45,7 +51,6 @@ class Version700 extends Version
'term',
'terms',
'wildcard',
'geo_distance',
'exists',
'percolate',
];
Expand Down

0 comments on commit 6039365

Please sign in to comment.