Skip to content

Commit 6039365

Browse files
committed
Update query builder query dsl
1 parent e62898f commit 6039365

File tree

2 files changed

+64
-15
lines changed

2 files changed

+64
-15
lines changed

lib/Elastica/QueryBuilder/DSL/Query.php

+56-12
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
use Elastica\Query\Exists;
1515
use Elastica\Query\FunctionScore;
1616
use Elastica\Query\Fuzzy;
17+
use Elastica\Query\GeoBoundingBox;
1718
use Elastica\Query\GeoDistance;
19+
use Elastica\Query\GeoPolygon;
1820
use Elastica\Query\HasChild;
1921
use Elastica\Query\HasParent;
2022
use Elastica\Query\Ids;
2123
use Elastica\Query\Match;
2224
use Elastica\Query\MatchAll;
2325
use Elastica\Query\MatchNone;
26+
use Elastica\Query\MatchPhrase;
27+
use Elastica\Query\MatchPhrasePrefix;
2428
use Elastica\Query\MoreLikeThis;
2529
use Elastica\Query\MultiMatch;
2630
use Elastica\Query\Nested;
@@ -159,6 +163,38 @@ public function fuzzy(string $fieldName = null, string $value = null): Fuzzy
159163
return new Fuzzy($fieldName, $value);
160164
}
161165

166+
/**
167+
* geo bounding box query.
168+
*
169+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html
170+
*/
171+
public function geo_bounding_box(string $key, array $coordinates): GeoBoundingBox
172+
{
173+
return new GeoBoundingBox($key, $coordinates);
174+
}
175+
176+
/**
177+
* geo distance query.
178+
*
179+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
180+
*
181+
* @param array|string $location
182+
*/
183+
public function geo_distance(string $key, $location, string $distance): GeoDistance
184+
{
185+
return new GeoDistance($key, $location, $distance);
186+
}
187+
188+
/**
189+
* geo polygon query.
190+
*
191+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html
192+
*/
193+
public function geo_polygon(string $key, array $points): GeoPolygon
194+
{
195+
return new GeoPolygon($key, $points);
196+
}
197+
162198
/**
163199
* geo shape query.
164200
*
@@ -225,6 +261,26 @@ public function match_none(): MatchNone
225261
return new MatchNone();
226262
}
227263

264+
/**
265+
* match phrase query.
266+
*
267+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase.html
268+
*/
269+
public function match_phrase(string $field = null, $values = null): MatchPhrase
270+
{
271+
return new MatchPhrase($field, $values);
272+
}
273+
274+
/**
275+
* match phrase prefix query.
276+
*
277+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-match-query-phrase-prefix.html
278+
*/
279+
public function match_phrase_prefix(string $field = null, $values = null): MatchPhrasePrefix
280+
{
281+
return new MatchPhrasePrefix($field, $values);
282+
}
283+
228284
/**
229285
* more like this query.
230286
*
@@ -432,18 +488,6 @@ public function wildcard(string $key = '', string $value = null, float $boost =
432488
return new Wildcard($key, $value, $boost);
433489
}
434490

435-
/**
436-
* geo distance query.
437-
*
438-
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html
439-
*
440-
* @param array|string $location
441-
*/
442-
public function geo_distance(string $key, $location, string $distance): GeoDistance
443-
{
444-
return new GeoDistance($key, $location, $distance);
445-
}
446-
447491
/**
448492
* exists query.
449493
*

lib/Elastica/QueryBuilder/Version/Version700.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@
1414
class Version700 extends Version
1515
{
1616
protected $queries = [
17-
'match',
18-
'multi_match',
1917
'bool',
2018
'boosting',
2119
'common_terms',
2220
'constant_score',
2321
'dis_max',
2422
'function_score',
2523
'fuzzy',
24+
'geo_bounding_box',
25+
'geo_distance',
26+
'geo_polygon',
2627
'geo_shape',
2728
'has_child',
2829
'has_parent',
2930
'ids',
31+
'match',
3032
'match_all',
33+
'match_none',
34+
'match_phrase',
35+
'match_phrase_prefix',
3136
'more_like_this',
37+
'multi_match',
3238
'nested',
3339
'parent_id',
3440
'prefix',
@@ -45,7 +51,6 @@ class Version700 extends Version
4551
'term',
4652
'terms',
4753
'wildcard',
48-
'geo_distance',
4954
'exists',
5055
'percolate',
5156
];

0 commit comments

Comments
 (0)