Disable search in "globalSearch"

Hi. I am confuse. DB is PostgreSQL. I have in Resource
protected static ?string $recordTitleAttribute = 'event_name';
protected static ?string $recordTitleAttribute = 'event_name';
As I understood, it's for global search and when I search, it's searches like:
SELECT *
FROM "businesses"
WHERE ("event_name"::text ilike '%pup%')
and "businesses"."deleted_at" IS NULL
LIMIT 50
SELECT *
FROM "businesses"
WHERE ("event_name"::text ilike '%pup%')
and "businesses"."deleted_at" IS NULL
LIMIT 50
But I have another column for full text search with index and I one to search by query:
SELECT *
FROM "businesses"
WHERE textsearchable_index_col @ @ to_tsquery('english', 'pup:*')
and "businesses"."deleted_at" IS NULL
SELECT *
FROM "businesses"
WHERE textsearchable_index_col @ @ to_tsquery('english', 'pup:*')
and "businesses"."deleted_at" IS NULL
When I rewrite "getGlobalSearchResults":
public static function getGlobalSearchResults(string $searchQuery): Collection
{

$customResults = Business::query()
->whereRaw("textsearchable_index_col @@ to_tsquery('english', ?)", [$searchQuery.':*'])
->get();

return parent::getGlobalSearchResults($searchQuery)
->concat($customResults)
->unique()
->values();
}
public static function getGlobalSearchResults(string $searchQuery): Collection
{

$customResults = Business::query()
->whereRaw("textsearchable_index_col @@ to_tsquery('english', ?)", [$searchQuery.':*'])
->get();

return parent::getGlobalSearchResults($searchQuery)
->concat($customResults)
->unique()
->values();
}
It's searches in both variants and returns result based on first (simple "ilike" search) If I remove $recordTitleAttribute, the its shows up menu without title (I see, that getGlobalSearchResults runs - searches) So, how to enable only my getGlobalSearchResults query and return event_name as the title in search result.
3 Replies
AlexAnder
AlexAnder12mo ago
Please, somebody comment..
Vp
Vp12mo ago
I didn't really understand what you exactly want, but check this out https://filamentphp.com/docs/2.x/admin/resources/global-search#multi-column-search
AlexAnder
AlexAnder12mo ago
What I wont is global search searches by custom sql and in the result returns event_name. Custom search searches by column, witch is tsvector date type and in response from search need to show different column