laravel-scout-mysql-driver
laravel-scout-mysql-driver copied to clipboard
Search on relationships
Hi there, I was using elasticsearch driver and I had no trouble indexing relationships like this:
public function toSearchableArray()
{
$array = $this->toArray();
// Customize array...
$array = remove_from_array($array, $this->appends);
$extra_data = [];
if ($this->company) {
$extra_data['company_name'] = $this->company->name;
}
return array_merge($array, $extra_data);
}
But have no idea how to achieve the same with mysql driver
A separate normalized search table would have to be created to support searching on relationship fields with this driver. I'll try and put some time aside this week to add easy support for this,
Hi, +1 to question. Any update on this?
Any update on this one?
Any updates? :)
+1
+1
@damiantw it's not necessary to create separate normalized search table. You can use left join and use joined table's fulltext index.
Example of working query: SELECT table_1.id, MATCH (table_1.name) AGAINST ('Query' IN BOOLEAN MODE) AS relevance_1, MATCH (table_2.name) AGAINST ('Query' IN BOOLEAN MODE) AS relevance_2 FROM table_1 LEFT JOIN table_2 ON table_1.id = table_2.foreign_id WHERE MATCH (table_1.name) AGAINST ('Query' IN BOOLEAN MODE) OR MATCH (table_2.name) AGAINST ('Query' IN BOOLEAN MODE) HAVING (relevance_1 + relevance_2) > 0 ORDER BY (relevance_1 + relevance_2) DESC
+1
any updates?
Anyone have a work around for how to get this to work?
https://github.com/ProVisionBG/searchable
- any updates?
- any updates?
@inkomomutane can you please point to the PR that solves the issue I am happy to merge it