relevanssi_didyoumean_query

apply_filters( 'relevanssi_didyoumean_query', string $query )

Filters the MySQL query used to fetch potential suggestions from the log.

Parameters

$query
(string) The MySQL query for fetching the suggestions.

More information

In the free version of Relevanssi (and as a fallback in Premium), Relevanssi gets the suggestions for the Did you mean feature from the search logs. By default Relevanssi fetches queries that have found at least 2 hits.

The query usually looks like this:

SELECT query, count(query) as c, AVG(hits) as a FROM wp_relevanssi_log
WHERE hits > 2 GROUP BY query ORDER BY count(query) DESC

The results from the query are stored in the transient option relevanssi_didyoumean_query for a month, because especially on a larger site the data doesn’t need to be fresh and this query can be expensive. Sometimes problems with the Did you mean suggestions can be solved by removing the relevanssi_didyoumean_query option.

Usually there’s little need for touching this query, as the number of hits required can be adjusted easily with the relevanssi_get_words_having filter hook.