studioespresso / craft-scout

Craft Scout provides a simple solution for adding full-text search to your entries. Scout will automatically keep your search indexes in sync with your entries.
MIT License
81 stars 55 forks source link

Make `SearchableBehavior::getRelatedElements()` configurable #273

Closed joshuapease closed 7 months ago

joshuapease commented 1 year ago

Overview

Bringing ticket https://github.com/studioespresso/craft-scout/issues/242 is back from the dead.


I'm working on a Craft Commerce site with about ~250,000~ 650,000 SKUs.

At that scale, we hit memory limit exceeded errors for some of our Entries that have lots of relationships to Products.

Commenting out these lines in SearchableBehavior::getRelatedElements resolved our issue.

This got me thinking... for many use cases, checking all of these Element Types is overkill. Most of our indexes only have relations between Entry and Asset elements.

Our project still need to index relations, but by removing most Element types from that check, we improve our performance by quite a bit.

janhenckens commented 7 months ago

Tested and this looks good to go @joshuapease. I'll get this into the Craft 4 version so you can hopefully "just" upgrade to 5 :)

joshuapease commented 7 months ago

No way! This made my Friday!

janhenckens commented 7 months ago

Cheers @joshuapease, thanks for contributing :)