Closed ADRDev closed 5 years ago
The following works for me as expected.
MyModel::search('term')->take(10)->get();
@ADRDev without any research it feels like expected behaviour.
it can be a result of with relevance ordering by search engine. https://github.com/teamtnt/laravel-scout-tntsearch-driver/issues/168
But MyModel::search('term')->get()
shouldnt return a collection of that structure.
If I do:
MyModel::search('term')->get()->take(10);
I get a collection with 10 results as expected.But if I do:
MyModel::search('term')->take(10)->get();
I get an empty collection.Digging into the issue it appears that the issue is with the indexing of the collection.
In the first example:
MyModel::search('term')->get()->take(10);
I get 10 elements, but the indexing is not 0-9, it has (seemingly to me) random index numbers.
Instead of 0, 1, 2, etc..
So it looks like somehow take(10) is trying to get array index 0-9 which are not set and thus returning an empty collection.
Any thoughts on this?