A way to make lazy search ?

I have a db with hundred thousand products. the in-built search freezes the table as it searches on type. I made a text input to make implement the search but it also searches on every letter typed. Is there a way to make the search happen only when the the focus changes or enter is pressed?

Filter::make('search')
                        ->form([
                            Forms\Components\TextInput::make('product_query')->label('Search Product (Name, SKU)'),
                        ])
                        ->columnSpanFull()
                        ->query(function (Builder $query, array $data): Builder {
                            return $query->when(
                                $data['product_query'],
                                fn (Builder $query): Builder => $query->where('name', 'ilike', "%{$data['product_query']}%")
                                    ->orWhere('sku', 'ilike', "%{$data['product_query']}%")
                            );
                        }),
Was this page helpful?