F
Filament3mo ago
Patie

OpenSearch/ElasticSearch

Hi, its possible to do searching,filtering and paginating without Scout on OpenSearch/ElasticSearch? How? Thank you!
5 Replies
Patie
PatieOP3mo ago
possible somehow like with this? applySearchToTableQuery protected function applyFiltersToTableQuery
protected function applyFiltersToTableQuery(Builder $query): Builder
{
$filters = $this->getTable()->getFilters();
// search in elastic and return ids
// $query->whereIn
return $query;
}
protected function applySearchToTableQuery(Builder $query): Builder
{
$search = $this->getTableSearch();
// search in elastic and return ids
// $query->whereIn
return $query;
}
protected function applyFiltersToTableQuery(Builder $query): Builder
{
$filters = $this->getTable()->getFilters();
// search in elastic and return ids
// $query->whereIn
return $query;
}
protected function applySearchToTableQuery(Builder $query): Builder
{
$search = $this->getTableSearch();
// search in elastic and return ids
// $query->whereIn
return $query;
}
is there better way? like method where i can do all at once?
Tonkawuck
Tonkawuck3mo ago
There is a modifyQueryUsing function have you tried that?
awcodes
awcodes3mo ago
I haven’t used elasticsearch personally, but as long as you are using an eloquent driver for it I would expect it to work in the same way as scout. https://filamentphp.com/docs/3.x/tables/advanced#searching-records-with-laravel-scout
Patie
PatieOP3mo ago
not sure if its the best way, its looks like my idea working (part of it is same as from documentation @awcodes , but its not documented well), anyway thank you
awcodes
awcodes3mo ago
If it’s working but you are needing it on more than one table, I would just make it a trait you can add to the components you need to.
Want results from more Discord servers?
Add your server