elastic / elasticsearch-rails

Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Apache License 2.0
3.07k stars 797 forks source link

Feature request: allow eager loading when searching across multiple models #990

Open SeanLF opened 3 years ago

SeanLF commented 3 years ago

When searching on a single model, we can chain methods like includes. However this fails when searching across multiple models:

search = Elasticsearch::Model.search(query: {}, [ModelA, ModelB])
db_records = search.records.includes(:association)

=> Elasticsearch::Transport::Transport::Errors::BadRequest

It'd be nice to be able to do this without having to monkey patch the library.