Posted on

Indexing with a cron job

I have some trouble with reindexing of new posts. The reason is simple – I sync data into the database automatically.

So what I need is a cronjob to reindex the site once a day. How do I do a cronjob?

The easiest way would be to get Relevanssi Premium and use WP CLI, so you can just say wp relevanssi index to get the job done.

If that’s not possible, you need to use the function relevanssi_build_index() to build the index. It’ll work fine, if your database is small enough so that you can index it in one go; if not, you need to run it several times, first with

relevanssi_build_index(false, false, X);

then

relevanssi_build_index(true, false, X);

as many times as is necessary, where X is a number of posts you are guaranteed to be able to index at one go.

This was asked at the WordPress.org support forums.

Leave a Reply

Your email address will not be published. Required fields are marked *