Revert "introduce wildcard, needs further testing"
This reverts commit 877533b43d.
This commit is contained in:
parent
23074a3a0c
commit
013f5162c5
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Blomstra\Search\Elasticsearch;
|
||||
|
||||
class WildcardQuery extends \Spatie\ElasticsearchQueryBuilder\Queries\WildcardQuery
|
||||
{
|
||||
protected float $boost = 1;
|
||||
protected bool $sensitivity = true;
|
||||
protected ?string $rewrite;
|
||||
|
||||
public function boost(float $boost = 1)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue