apply_filters( 'relevanssi_indexing_query', string $query )
Filters the MySQL query that is used to fetch the posts that are indexed.
Parameters
$query
(string) The MySQL query for fetching the posts.
More information
Relevanssi uses relevanssi_generate_indexing_query()
to generate the query that fetches the posts that are indexed. The query looks something like this:
SELECT post.ID FROM wp_posts post LEFT JOIN wp_posts parent ON (post.post_parent=parent.ID) WHERE (post.post_status IN ('publish','draft','private') OR (post.post_status='inherit' AND( (parent.ID is not null AND (parent.post_status IN ('publish','draft','private'))) OR (post.post_parent=0) )) ) ORDER BY post.ID DESC
This is for the initial indexing, and when the indexing is continued, it looks something like this:
SELECT post.ID FROM wp_posts post LEFT JOIN wp_posts parent ON (post.post_parent=parent.ID) LEFT JOIN wp_relevanssi r ON (post.ID=r.doc) WHERE r.doc IS NULL AND( post.post_status IN ('publish','draft','private') OR (post.post_status='inherit' AND( (parent.ID is not null AND (parent.post_status IN ('publish','draft','private'))) OR (post.post_parent=0) )) ) ORDER BY post.ID DESC
In general this filter hook is best used for debugging purposes. For most part, you don’t want to modify this query directly, but instead you want to do the possible manipulation with relevanssi_indexing_restriction
, which is used to add extra restrictions to this query.