apply_filters( 'relevanssi_query_filter', string $query )
This filter hook filters the MySQL Relevanssi uses to fetch results from the database.
Parameters
$query
(string) The MySQL query that Relevanssi uses to fetch the results.
More information
There are many steps in the Relevanssi searching process. During the searching, Relevanssi generates a MySQL query to fetch the results from the Relevanssi database table.
You can use this filter hook to modify the search query. However, that’s generally not useful. There’s probably a better way to achieve things you could achieve with this filter hook. This filter hook is best for debugging the search query:
add_filter( 'relevanssi_query_filter', 'rlv_debug_query' ); function rlv_debug_query( $query ) { error_log( $query ); // Log to PHP error log. var_dump( $query ); // Print out query on the screen. return $query; }
If you use this filter hook for modifications, make sure you make the same modifications to the DF query with the relevanssi_df_query_filter
hook.
To modify different parts of the query, you can use other filter hooks:
relevanssi_fuzzy_query
filters the term in partial matching.relevanssi_join
filters the JOIN part of the query.relevanssi_term_where
filters the term part.relevanssi_where
filters the query restrictions.
Relevanssi adds a filter function relevanssi_limit_filter
on this filter hook to limit the number of results fetched from the database, based on the throttle settings.