laravel/scout

Meilisearch facetDistribution / raw attributes

martinsnajdr opened this issue · 3 comments

Hello,

I'm working on a simple application that has a results listing and faceted search using Scout/Meilisearch. If I use the get/paginate() function, Scout takes the results, creates an EloquentCollection/LengthAwarePaginator out of them and I can work with them further as I'm used to. However, it is only within the raw/paginateRaw() function that I am able to get the facetDistribution field, which contains the data for the facets that can be used to build a facet search fieldsets. However, raw/paginateRaw on the other hand contains hits in the form of an array (not an EloquentCollection / LengthAwarePaginator), which is not as usable as EloquentCollection.

I kind of understand that different engines (Algolia, Meilisearch) work differently with facets (and other parameters), so you can't make some abstraction that covers everything (or is compatible with all engines), but I still think that get/paginate functions should at least return the rest of the raw attributes...

Or at least there should be some way to take the array returned by the raw/paginateRaw() function, take the raw attributes from that, and transform the raw hits into an EloquentCollection / LengthAwarePaginator.

Right now my working solution is to make two search queries, one raw and one paginated.

Also I have noticed that macros were removed from the Scout documentation...

Thank you for any tips / explanation.

I @martinsnajdr. If you could send in a PR then we can look at what is involved to maybe get this into Scout. Thanks!