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() overrides the Meilisearch's rank. How to disable the defaultSort() while on search?

$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;
}
Was this page helpful?