"Full text search is pretty vendor specific and not something that is currently supported by Laravel. You would need to run a raw query." https://github.com/laravel/framework/issues/214#issuecomment-12916104
Still the same case.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I'm trying to build a query to do a full text search on products. I've been using Eloquent to build up the query based on a number of other factors such as pagination, order etc.
I'm not using full text every time so how I'd got it is roughly like this (if i was doing a full text):
public function getProducts($input['string'])
{
$query = $this->model->query();
if($fulltext)
{
$query = $this->searchProductsFulltext($input['string']);
}
$query->where('product_active', '=', 'y');
$order = (isset($input['sort'])) ? $input['sort'] : 'order';
return $query->orderBy($order, 'asc')->paginate(50);
}
public function searchProductsFulltext($string)
{
return $this->model->whereRaw('match (title, description) against (? in boolean mode)', [$string]);
}
This works fine in terms of returning results just not the most relevant ones. So i've got a new query:
select product.*
, match(`title`) against('$string' in boolean mode) as relevance_1
, match(`description`) against('$string' in boolean mode) as relevance_2
from product
where match(`title`, `description`) against ('$string' in boolean mode)
order by (relevance_1 * 2) + relevance_2 desc;
This one works fine but just wondering if there's a way to keep this in eloquent or if I just have to do a raw query.
Thanks
Please or to participate in this conversation.