apply_filters( 'relevanssi_didyoumean_query', string $query )
Filters the MySQL query used to fetch potential suggestions from the log.
(string) The MySQL query for fetching the suggestions.
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
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.