From f1d90903a27451ba668ed21ad96bfdf0e6077150 Mon Sep 17 00:00:00 2001 From: Dimitar Vladimirov Date: Wed, 4 Dec 2019 15:14:50 +0200 Subject: [PATCH 1/2] exclude from text --- src/Builders/FilterBuilder.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Builders/FilterBuilder.php b/src/Builders/FilterBuilder.php index 792378a..98b4acc 100644 --- a/src/Builders/FilterBuilder.php +++ b/src/Builders/FilterBuilder.php @@ -151,6 +151,27 @@ public function where($field, $value) return $this; } + /** + * Exclude results containing text + * Can't use it 'term' because it's not analyzed + * + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html Terms query + * + * @param string $field + * @param array $value + * @return $this + */ + public function whereNotInText($field, $value) + { + $this->wheres['must_not'][] = [ + 'match_phrase' => [ + $field => $value + ] + ]; + + return $this; + } + /** * Add a whereIn condition. * From 05c1f798ac14f2c22a2493759b635fa31e2bf49c Mon Sep 17 00:00:00 2001 From: Dimitar Vladimirov Date: Thu, 19 Dec 2019 17:33:23 +0200 Subject: [PATCH 2/2] add whereMatch --- src/Builders/FilterBuilder.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Builders/FilterBuilder.php b/src/Builders/FilterBuilder.php index 98b4acc..d0dc625 100644 --- a/src/Builders/FilterBuilder.php +++ b/src/Builders/FilterBuilder.php @@ -153,7 +153,7 @@ public function where($field, $value) /** * Exclude results containing text - * Can't use it 'term' because it's not analyzed + * Can't use 'term' because it's not analyzed * * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html Terms query * @@ -172,6 +172,23 @@ public function whereNotInText($field, $value) return $this; } + /** + * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/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; + } + /** * Add a whereIn condition. *