Reputation: 728
So far when I try column filtering I'm able to use LIKE or REGEXP but nether of them are using table indexes, which is a great concern given the amount of data I need to filter.
Is there a way to get an exact match using indexes? (DB indexes)
I'm using: https://github.com/yajra/laravel-datatables v6.11.3 and https://datatables.net v1.10.10
Upvotes: 2
Views: 1041
Reputation: 41400
With datatables laravel package you can customise parameter search on laravel side in lookup function with the "filterColumn" function. Like so:
return Datatables::of($users)
->filterColumn('user_id', function($query, $keyword) {
$query->whereRaw("CONCAT(users.id,'-',users.id) like ?", ["%{$keyword}%"]);
})
->make(true);
See more in Documentation
Upvotes: 3