scout-elasticsearch-driver icon indicating copy to clipboard operation
scout-elasticsearch-driver copied to clipboard

Allow BulkIndexer to load relations efficiently when called from a queue

Open clovenlife opened this issue 6 years ago • 0 comments
trafficstars

Because Scout passes all models through MakeSerachable class when using a queue. The class uses the SerializesModels trait and any eager loaded relations will no longer be present when the queued job is run.

Since these relations are gone, BulkIndexer causes a query for every model when it reaches toSearchableArray(). By adding loadMissing and passing in desired relations via a property on the model class loads relations for that chunk without adding cost to single threaded uses

clovenlife avatar Apr 17 '19 18:04 clovenlife