© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
3 replies
QCTFW

Disable Default Sort while Searching with Scout

I use Laravel Scout with Meilisearch for table search. I want to sort the table based on Meilisearch's rank but
defaultSort()
defaultSort()
overrides the Meilisearch's rank. How to disable the
defaultSort()
defaultSort()
while on search?

$table
  ->selectCurrentPageOnly()
  ->defaultSort('name', 'asc')
  ->searchDebounce('500ms')
  ->columns([...])
  ->filters([...])
  ->actions([...]);
$table
  ->selectCurrentPageOnly()
  ->defaultSort('name', 'asc')
  ->searchDebounce('500ms')
  ->columns([...])
  ->filters([...])
  ->actions([...]);


protected function applySearchToTableQuery(Builder $query): Builder
{
    $this->applyColumnSearchesToTableQuery($query);

    if (filled($search = $this->getTableSearch())) {
        $meiliBuilder = Book::search($search);

        $query->whereIn('id', $meiliBuilder->keys());

        // Already tried this but still not working
        $this->tableSortColumn = null;
        $this->tableSortDirection = null;
    }

    return $query;
}
protected function applySearchToTableQuery(Builder $query): Builder
{
    $this->applyColumnSearchesToTableQuery($query);

    if (filled($search = $this->getTableSearch())) {
        $meiliBuilder = Book::search($search);

        $query->whereIn('id', $meiliBuilder->keys());

        // Already tried this but still not working
        $this->tableSortColumn = null;
        $this->tableSortDirection = null;
    }

    return $query;
}
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Disable table actions while searching
FilamentFFilament / ❓┊help
2y ago
I am using Laravel Scout with Meilisearch issue with Default Sortting
FilamentFFilament / ❓┊help
3y ago
Table groups change default sort
FilamentFFilament / ❓┊help
3y ago
Multiple default sort in tables
FilamentFFilament / ❓┊help
3y ago