Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for async association reindex #1485

Closed
gbxl opened this issue May 7, 2021 · 2 comments
Closed

Allow for async association reindex #1485

gbxl opened this issue May 7, 2021 · 2 comments

Comments

@gbxl
Copy link

gbxl commented May 7, 2021

Is your feature request related to a problem? Please describe.
When reindexing a model, I want to trigger a reindex on some associations. Currently, I have some custom code that decides whether that association should be reindexed. If it is, I can only call association.reindex. I tried using association.reindex(async: true) but that doesn't work, the async option gets dropped when calling import_scope(relation, scope: scope) in lib/searchkick/index.rb -> def reindex

Describe the solution you'd like
Can we pass along the options to the import_scope? I tried locally and in my older version of the gem (4.1.1) it complains about refresh and mode but since the newer version of the gem already removes the refresh option, we'd just need to delete mode and we'd be good to go. I think this would be very beneficial for large associations, in order to leverage the BulkReindexer vs loading everything in batches synchronously 🤒

Happy to open a PR to handle that but wanted to check with you that I'm not missing some purposeful restriction first :)

@ankane
Copy link
Owner

ankane commented May 20, 2021

Hey @gbxl, thanks for the suggestion. This is part of the plan for Searchkick 5 (#1288). I'm planning to make significant changes to the reindexing logic, so want to hold off until then.

@ankane
Copy link
Owner

ankane commented Feb 22, 2022

Hey @gbxl, still need to add the documentation, but in Searchkick 5 (just released), you can do:

association.reindex(mode: :async)

(for full reindex, you'll still need to use async: true for now, but that'll be deprecated and changed to mode in a future release)

Thanks again for the suggestion.

@ankane ankane closed this as completed Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants