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

Commit a386b4b

Browse files
committed
- Added test for geo shape filter
- Added docs for geo shape filter
1 parent fe5a2fe commit a386b4b

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ whereRegexp($field, $value, $flags = 'ALL') | whereRegexp('name.raw', 'A.+') | F
424424
whereGeoDistance($field, $value, $distance) | whereGeoDistance('location', [-70, 40], '1000m') | Filters records according to given point and distance from it. [Here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-query.html) you can find more about syntax.
425425
whereGeoBoundingBox($field, array $value) | whereGeoBoundingBox('location', ['top_left' => [-74.1, 40.73], 'bottom_right' => [-71.12, 40.01]]) | Filters records within given boundings. [Here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html) you can find more about syntax.
426426
whereGeoPolygon($field, array $points) | whereGeoPolygon('location', [[-70, 40],[-80, 30],[-90, 20]]) | Filters records within given polygon. [Here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html) you can find more about syntax.
427+
whereGeoShape($field, array $shape) | whereGeoShape('shape', ['type' => 'circle', 'radius' => '1km', 'coordinates' => [4, 52]]) | Filters records within given shape. [Here](https://www.elastic.co/guide/en/elasticsearch/guide/current/querying-geo-shapes.html) you can find more about syntax.
427428

428429
In most cases it's better to use raw fields to filter records, i.e. not analyzed fields.
429430

tests/Builders/FilterBuilderTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,37 @@ public function testWhereGeoPolygon()
339339
);
340340
}
341341

342+
public function testWhereGeoShape()
343+
{
344+
$shape = [
345+
'type' => 'circle',
346+
'radius' => '1km',
347+
'coordinates' => [
348+
4.89994,
349+
52.37815
350+
]
351+
];
352+
353+
$builder = (new FilterBuilder($this->mockModel()))
354+
->whereGeoShape('foo', $shape);
355+
356+
$this->assertEquals(
357+
[
358+
'must' => [
359+
[
360+
'geo_shape' => [
361+
'foo' => [
362+
'shape' => $shape
363+
]
364+
]
365+
]
366+
],
367+
'must_not' => []
368+
],
369+
$builder->wheres
370+
);
371+
}
372+
342373
public function testOrderBy()
343374
{
344375
$builder = (new FilterBuilder($this->mockModel()))

0 commit comments

Comments
 (0)