diff --git a/src/Api/Controllers/SearchController.php b/src/Api/Controllers/SearchController.php index 9caad2b..57b03b8 100644 --- a/src/Api/Controllers/SearchController.php +++ b/src/Api/Controllers/SearchController.php @@ -4,7 +4,6 @@ namespace Blomstra\Search\Api\Controllers; use Blomstra\Search\Elasticsearch\MatchPhraseQuery; use Blomstra\Search\Elasticsearch\MatchQuery; -use Blomstra\Search\Elasticsearch\WildcardQuery; use Blomstra\Search\Save\Document as ElasticDocument; use Blomstra\Search\Elasticsearch\TermsQuery; use Elasticsearch\Client; @@ -205,10 +204,7 @@ class SearchController extends ListDiscussionsController protected function partialMatch(string $q) { - return (new WildcardQuery('content', "*$q*")) - ->caseSensitivity(false) - ->rewrite('constant_score_boolean') - ->boost(.2); + return (new MatchQuery('content', "*$q*"))->boost(.2); } protected function getGroups(User $actor): Collection diff --git a/src/Elasticsearch/WildcardQuery.php b/src/Elasticsearch/WildcardQuery.php deleted file mode 100644 index 0b5fb44..0000000 --- a/src/Elasticsearch/WildcardQuery.php +++ /dev/null @@ -1,46 +0,0 @@ -boost = $boost; - - return $this; - } - - public function caseSensitivity(bool $sensitivity = true) - { - $this->sensitivity = $sensitivity; - - return $this; - } - - public function rewrite(string $rewrite = null) - { - $this->rewrite = $rewrite; - - return $this; - } - - public function toArray(): array - { - $query = parent::toArray(); - - $query['wildcard'][$this->field]['boost'] = $this->boost; - $query['wildcard'][$this->field]['case_insensitive'] = ! $this->sensitivity; - - if ($this->rewrite) { - $query['wildcard'][$this->field]['rewrite'] = $this->rewrite; - - } - - return $query; - } -}