apply_filters( 'relevanssi_get_words_having', int $having )

Limits the words used for Did you mean suggestions to improve performance.


(int) The value for the MySQL query, default 2.

More information

The Did you mean suggestions use material from your database to create the suggestions. In the free version, the successful queries from the search logs are used, while Premium uses the words in your database index. Both may need to limit the number of data used to increase the performance, and this filter hook is used for that.

In the free version, the query 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

In Premium, the query is:

SELECT term,
  SUM(title + content + comment + tag + link + author + category + excerpt + taxonomy + customfield) AS c
  FROM wp_relevanssi
  GROUP BY term HAVING c > 2

This filter hook lets you change the 2 in both queries:

add_filter( 'relevanssi_get_words_having', function() { return 3; } );

Small increments are good here.