Updates the relevanssi_words cache option with new content.

Source: /premium/common.php


This function regenerates the word cache Relevanssi Premium Did you mean? functionality uses to generate the suggestions.

The function fetches all the words from the Relevanssi index that appear at least twice in the database. The result of the query is stored in the relevanssi_words option in the wp_options database table with an expiry time of one month.

In general, there’s no need to call this function directly. Relevanssi will call this function with an AJAX action whenever the relevanssi_words option is empty or when the data is expired. This can be a slow process, and thus is performed with an AJAX action.

Sometimes the AJAX action fails to work, in which case it may be helpful to call this function directly. For example, to make this function run every week, you can add this to your site:

add_action( 'after_setup_theme', function() {
  if ( ! wp_next_scheduled( 'relevanssi_words_weekly_update' ) ) {
    wp_schedule_event( time(), 'weekly', 'relevanssi_words_weekly_update' );
add_action( 'relevanssi_words_weekly_update', function() { relevanssi_update_words_option(); } );

Another approach is to make this function trigger every time a post is updated by hooking it into wp_insert_post filter hook on a sufficiently late priority, but this makes saving posts slower, and that’s not good.

Filter hooks

relevanssi_get_words_having – Controls the minimum number of occurrences for the words.