Open thekonz opened 4 years ago
If I understand this extra sql query check if column support fulltext search. I think this check should not even be required but only use toSearchableArray() Is developer's responsibility to make sure that full text search has been created correctly. Maybe just add an extra toSearchableFulltextArray() which will be only columns that are "full textable"
I check into code a bit more and seem that this extra query is executed for select and where, because we can't access toSearchableArray().
A possible workaround could be to add a static method or property into model with array of columns searchable and one fulltextable if different from searchable.
Then in ModelService change method:
public function getFullTextIndexFields()
{
return $this->model::$fulltextable;
}
public function getSearchableFields()
{
return $this->model::$searchable;
}
And we could also access directly from builder using $builder->model::$searchable
I saw that this package added a lot of queries to my application and at the part that adds the queries, you can see a comment
@TODO cache this.
.https://github.com/yabhq/laravel-scout-mysql-driver/blob/b777fcbdd90e5d701ae1d31c1910e9d2e0815f54/src/Services/ModelService.php#L50
Same thing in the
getAllFields
method.I suggest adding a command
scout:mysql-cache
.Is there anything preventing us from caching? Otherwise I'll gladly add a PR.