mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-10 00:34:50 +00:00
Update SearchApiV2Service, fix postgres hashtag search and prepend wildcard operator to improve results
This commit is contained in:
parent
867cbc757c
commit
6e20d0a670
1 changed files with 4 additions and 2 deletions
|
@ -125,8 +125,10 @@ class SearchApiV2Service
|
||||||
$q = $this->query->input('q');
|
$q = $this->query->input('q');
|
||||||
$limit = $this->query->input('limit') ?? 20;
|
$limit = $this->query->input('limit') ?? 20;
|
||||||
$offset = $this->query->input('offset') ?? 0;
|
$offset = $this->query->input('offset') ?? 0;
|
||||||
$query = Str::startsWith($q, '#') ? substr($q, 1) . '%' : $q . '%';
|
$query = Str::startsWith($q, '#') ? '%' . substr($q, 1) . '%' : '%' . $q . '%';
|
||||||
return Hashtag::where('name', 'like', $query)
|
$operator = config('database.default') === 'pgsql' ? 'ilike' : 'like';
|
||||||
|
return Hashtag::where('name', $operator, $query)
|
||||||
|
->orWhere('slug', $operator, $query)
|
||||||
->where(function($q) {
|
->where(function($q) {
|
||||||
return $q->where('can_search', true)
|
return $q->where('can_search', true)
|
||||||
->orWhereNull('can_search');
|
->orWhereNull('can_search');
|
||||||
|
|
Loading…
Reference in a new issue