Skip to content

Commit

Permalink
Merge pull request #59 from l3aro/main
Browse files Browse the repository at this point in the history
Support operator in MatchQuery
  • Loading branch information
freekmurze authored Jan 17, 2025
2 parents 8d23b48 + 8d5ad7b commit 482bb8b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Queries/MatchQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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'
) {
}

Expand All @@ -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;
}
}

0 comments on commit 482bb8b

Please sign in to comment.