Lazy load not working
StefanFPF opened this issue · 2 comments
First
Search existing issues to see if it’s been reported and make sure you’re on the latest version.
Describe the bug
I'm trying to use the multi_search feature to batch a couple searches into a single network roundtrip. However, if I follow the documented behavior, the query gets executed immediately before I can pass the query to multi_search to actually be executed.
Both Post.search(limit:1, load:false);
and Post.search(limit:1, load:false).to_a
result in an actual ES query, which I want to avoid, since I want ti to be handled by multi_search
This does not reflect the documented behavior and the commit here:
329e053
To reproduce
run a Product.search(debug: true) and see that the ES query is actually eagerly executed
Additional context
In the above commit, it probably could use a test case to verify that the search actually returns a Query object instead of a result array. From what I understand it just makes the existing behavior pass.
Hi @StefanFPF, lazy loading works fine.
Thanks for the quick reply. I see what's going on - I was testing in the rails console and irb by default pretty prints the result, so it is calling Relation.inspect
... Looking at the code this delegates to execute_internal, so that's why it executed for me. Outside of irb or when setting config.echo to false in irb, the lazy loading worked in the console as well. Pretty new to Rails, sorry for the Friday evening bug report :(