diff --git a/src/Domain/Syntax/GeoDistance.php b/src/Domain/Syntax/GeoDistance.php new file mode 100644 index 0000000..083ecc7 --- /dev/null +++ b/src/Domain/Syntax/GeoDistance.php @@ -0,0 +1,51 @@ +distance = $distance; + $this->lat = $lat; + $this->lng = $lng; + $this->field = $field; + $this->distance_type = $distance_type; + } + + public function build(): array + { + return [ + 'geo_distance' => [ + 'distance' => (string) $this->distance, + 'distance_type' => (string) $this->distance_type, + $this->field => [ + 'lat' => (string) $this->lat, + 'lon' => (string) $this->lng + ] + ] + ]; + } + +} diff --git a/src/Infrastructure/Scout/Builder.php b/src/Infrastructure/Scout/Builder.php index 28ac51c..0d219f6 100644 --- a/src/Infrastructure/Scout/Builder.php +++ b/src/Infrastructure/Scout/Builder.php @@ -21,6 +21,8 @@ class Builder extends \Laravel\Scout\Builder public array $fields = []; + public array $orders = []; + public ?BoolQuery $compound = null; public array $aggregations = []; @@ -33,6 +35,12 @@ public function must($must): self return $this; } + public function order($order): self + { + $this->orders[] = $order; + return $this; + } + public function should($should): self { $this->should[] = $should;