I know we have re-index options via settings pages, and we have a WP-CLI command that can also be used for bulk re-indexing. Those are probably the best options at the moment.
Otherwise, I think we’d need to look into triggering a bulk re-index on delete. That said, I wonder if all is well when re-assigning the user’s generated content to a different user.
Thread Starter
Andrea
(@licoreo)
i neri that is automate, esiste an action to trigger reindexing of single indice?
With the WP-CLI, you can specify which index to re-index.
Example:
wp algolia reindex posts_post
https://github.com/WebDevStudios/wp-search-with-algolia/wiki/WP-CLI
With the UI in browser and WP admin, each has their own.
Thread Starter
Andrea
(@licoreo)
exists a way to do with php?
Let me have a chance to dig in to some things and I’ll get back to you asap.
I remembered a case where I set up re-indexing specific posts, in this case WooCommerce products, upon completed purchases, so this is adapted from that.
https://gist.github.com/tw2113/3f8729526bc25c3778a41e42f9173601
Out of box for this, it’ll just do the searchable_posts index, and any index for autocomplete will need to be added. There’s commented out code for that and notes on how to handle that. Hopefully that section makes sense, but feel free to ask questions.
That said, this code was originally meant to handle only 1 post/object at a time, and in your situation, it’s a complete reindex of everything in the index. I can’t promise anything around timeouts for the request and whatnot, so performance may be degraded, especially for big indexes.
Because of that as well, I don’t think we’d consider adding this to the core plugin. It’d be better adapting this to some sort of background action scheduler with a queue. However, at minimum, this snippet shows how to potentially set things up and run things on a specific action.
Thread Starter
Andrea
(@licoreo)
Hello,
looks a great solution, thank you!
Hopefully not a huge amount of performance is lost because of the volume of re-indexing.