algoliasearch-wordpress icon indicating copy to clipboard operation
algoliasearch-wordpress copied to clipboard

Question: How to trigger a re-index programmatically for a single custom type

Open davedbase opened this issue 7 years ago • 3 comments

Hi there,

Sorry if this is not the correct place to post this question, but I'm curious how I can go about forcing a custom type re-index (just one specific record) to Algolia. Our platform has a couple automated procedures that effect the database directly (postmeta specifically) and WP may not directly know about the changes. For this reason we'd like a process to force a trigger.

Thanks,

David

davedbase avatar Dec 04 '18 22:12 davedbase

Hi @ddibiase ,

The easiest way to force a re-index on a post is to update it via the wp_update_post function: https://codex.wordpress.org/Function_Reference/wp_update_post. This should trigger a re-index in Algolia.

rayrutjes avatar Dec 05 '18 09:12 rayrutjes

Is there an easier way, we perform a lot of batch updates and to trigger the whole post update function is a bit heavy on the platform.

davedbase avatar Dec 07 '18 16:12 davedbase

Another approach would consist of re-indexing everything at a chosen rate leveraging the wp-cli commands shipped with the plugin: https://community.algolia.com/wordpress/wp-cli.html#algolia-search

rayrutjes avatar Dec 07 '18 16:12 rayrutjes