10up / ElasticPress

A fast and flexible search and query engine for WordPress.
https://elasticpress.io
GNU General Public License v2.0
1.24k stars 312 forks source link

Listen to switch_blog event and clear index queue #3883

Closed itzikbenh closed 5 months ago

itzikbenh commented 5 months ago

Is your enhancement related to a problem? Please describe.

I have a multisite and would've been nice to use switch_to_blog to copy content across sites, but ElasticPress attempts to bulk index them to the index of the initial blog_id, which makes it not possible.

Designs

Right now you're listening to the shutdown event to run index_sync_queue, maybe add a custom hook and let users trigger it, that way we can clear the queue in between blog switches.

Describe alternatives you've considered

No response

Code of Conduct

itzikbenh commented 5 months ago

It does seem like I could bypass this by running this on each blog iteration:

Indexables::factory()->get( 'post' )->sync_manager->index_sync_queue();
Indexables::factory()->get( 'term' )->sync_manager->index_sync_queue();

However, it's not really documented, so not sure if this is a recommended way.

itzikbenh commented 5 months ago

I realize I'm on an older version of this plugin and it's actually fixed. My apologies :).