teamtnt / laravel-scout-tntsearch-driver

Driver for Laravel Scout search package based on https://github.com/teamtnt/tntsearch
MIT License
1.1k stars 144 forks source link

Cannot use tntsearch:import when relations are involved #98

Closed nbolender closed 3 months ago

nbolender commented 7 years ago

Just putting this here to maybe encourage someone to update the documentation.

It seems you cannot use tntsearch:import if you use lazy-loading relations in your toSearchableArray() function. Using scout:import works fine. I assume that tntsearch:import goes straight to the database and that's why it's faster, but it makes relations hard to work with.

jasonlfunk commented 5 years ago

It is also worth noting that since the tntsearch:import method pulls directly from the database, any custom fields that you add to the array won't be indexed. For example, if you manually create your own ngrams for a field and store it, they will not show up. This got me stuck for awhile. The documentation should be updated to note this or even better, the tntsearch:import should warn you when it notices you are added columns that aren't in the database. There is definitely a use-case for pulling directly from the db - but the documentation gives the impression that it works the same as scout:import but just faster.