Skip to content
This repository was archived by the owner on Nov 4, 2021. It is now read-only.

Commit 93087e4

Browse files
author
Michael Nguyen
committed
added $relation to whereGeoShape
1 parent b27f9c3 commit 93087e4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/Builders/FilterBuilder.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,18 +328,20 @@ public function whereGeoPolygon($field, array $points)
328328
}
329329

330330
/**
331-
* @see https://www.elastic.co/guide/en/elasticsearch/guide/current/querying-geo-shapes.html Querying Geo Shapes
331+
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-shape-query.html Querying Geo Shapes
332332
*
333333
* @param string $field
334334
* @param array $shape
335+
* @param string $relation
335336
* @return $this
336337
*/
337-
public function whereGeoShape($field, array $shape)
338+
public function whereGeoShape($field, array $shape, $relation = 'intersects')
338339
{
339340
$this->wheres['must'][] = [
340341
'geo_shape' => [
341342
$field => [
342-
'shape' => $shape
343+
'shape' => $shape,
344+
'relation' => $relation
343345
]
344346
]
345347
];

tests/Builders/FilterBuilderTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,16 +350,19 @@ public function testWhereGeoShape()
350350
]
351351
];
352352

353+
$relation = 'intersects';
354+
353355
$builder = (new FilterBuilder($this->mockModel()))
354-
->whereGeoShape('foo', $shape);
356+
->whereGeoShape('foo', $shape, $relation);
355357

356358
$this->assertEquals(
357359
[
358360
'must' => [
359361
[
360362
'geo_shape' => [
361363
'foo' => [
362-
'shape' => $shape
364+
'shape' => $shape,
365+
'relation' => $relation
363366
]
364367
]
365368
]

0 commit comments

Comments
 (0)