Table Builder + Scout: Search Result Order

Currently, if I use https://filamentphp.com/docs/3.x/tables/advanced#searching-records-with-laravel-scout to integrate table builder with scout, the search results are ordered by the id number of the record, meaning that the most relevant search result is often not at the top because it has a larger id value.

I want the search results in the table builder to be ordered by order that scout returns. What would be the best way to approach this?

For reference: this is the query that table builder tries to execute. When the search bar is filled, I don't want the results to be ordered by id, but by the order that scout returns.

SELECT
  *
FROM
  [ table ]
WHERE
  [ id ] IN (
    ...
  )
ORDER BY
  [ table ].[ id ] ASC OFFSET 10 ROWS FETCH next 10 ROWS ONLY
Was this page helpful?