meilisearch / meilisearch-rails

Meilisearch integration for Ruby on Rails
https://www.meilisearch.com
MIT License
311 stars 47 forks source link

Add a scope parameter to eager load matched records #233

Open DavertMik opened 1 year ago

DavertMik commented 1 year ago

Description It would be nice if this gem could to eager load relations of matched records

class Book
  scope with_author: -> { includes(:author) }
end

Book.search('Harry Potter', scope: :with_author)

I would add an optional scope parameter and used it here to load relations https://github.com/meilisearch/meilisearch-rails/blob/main/lib/meilisearch-rails.rb#L653

brunoocasali commented 1 year ago

Hi @DavertMik sorry for the late reply. Indeed it would be a nice addition, I go further if we had something like this:

Book.with_author.with_reviews.search('Harry Potter')