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

Adds match filter #417

Open
wants to merge 2 commits into
base: v3.12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,9 @@ whereNotIn($field, $value) | whereNotIn('id', [1, 2, 3]) | Checks if a value isn
whereBetween($field, $value) | whereBetween('price', [100, 200]) | Checks if a value is in a range.
whereNotBetween($field, $value) | whereNotBetween('price', [100, 200]) | Checks if a value isn't in a range.
whereExists($field) | whereExists('unemployed') | Checks if a value is defined.
whereNotExists($field) | whereNotExists('unemployed') | Checks if a value isn't defined.
whereNotExists($field) | whereNotExists('unemployed') | Checks if a value isn't define.
whereMatch($field, $value) | whereMatch('tags', 'travel') | Filters records matching exact value. [Here](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-match-query.html) you can find more about syntax.
whereNotMatch($field, $value) | whereNotMatch('tags', 'travel') | Filters records not matching exact value. [Here](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-match-query.html) you can find more about syntax.
whereRegexp($field, $value, $flags = 'ALL') | whereRegexp('name.raw', 'A.+') | Filters records according to a given regular expression. [Here](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-syntax) you can find more about syntax.
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.
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.
Expand Down
36 changes: 36 additions & 0 deletions src/Builders/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,42 @@ public function whereNotExists($field)
return $this;
}

/**
* @see https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-match-query.html Match query
*
* @param string $field
* @param string $value
* @return $this
*/
public function whereMatch($field, $value)
{
$this->wheres['must'][] = [
'match' => [
$field => $value,
],
];

return $this;
}

/**
* @see https://www.elastic.co/guide/en/elasticsearch/reference/6.8/query-dsl-match-query.html Match query
*
* @param string $field
* @param string $value
* @return $this
*/
public function whereNotMatch($field, $value)
{
$this->wheres['must_not'][] = [
'match' => [
$field => $value,
],
];

return $this;
}

/**
* Add a whereRegexp condition.
*
Expand Down