From 8d5ad7ba8a2172e5ce0e88b74c7c45d01c2b5f49 Mon Sep 17 00:00:00 2001 From: l3aro Date: Fri, 17 Jan 2025 11:34:52 +0700 Subject: [PATCH] Support operator in MatchQuery --- src/Queries/MatchQuery.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Queries/MatchQuery.php b/src/Queries/MatchQuery.php index dd6862b..ce3dbf4 100644 --- a/src/Queries/MatchQuery.php +++ b/src/Queries/MatchQuery.php @@ -8,7 +8,8 @@ public static function create( string $field, string | int $query, null | string | int $fuzziness = null, - null | float $boost = null + null | float $boost = null, + null | string $operator = 'or' ): self { return new self($field, $query, $fuzziness, $boost); } @@ -17,7 +18,8 @@ public function __construct( protected string $field, protected string | int $query, protected null | string | int $fuzziness = null, - protected null | float $boost = null + protected null | float $boost = null, + protected null | string $operator = 'or' ) { } @@ -39,6 +41,10 @@ public function toArray(): array $match['match'][$this->field]['boost'] = $this->boost; } + if ($this->operator) { + $match['match'][$this->field]['operator'] = $this->operator; + } + return $match; } }