Wordpress uses a simple MySQL LIKE
search for the Core search feature. You can see that by running a simple test case like this:
$q = new WP_Query(array('s' => 'test'));
var_dump($q->request);
die;
You should see something like (Formatted courtesy of http://sqlformat.org/):
SELECT SQL_CALC_FOUND_ROWS dev_posts.ID
FROM dev_posts
WHERE 1=1
AND (((dev_posts.post_title LIKE '%test%')
OR (dev_posts.post_content LIKE '%test%')))
AND (dev_posts.post_password = '')
AND dev_posts.post_type IN ('post',
'page',
'attachment',
'book')
AND (dev_posts.post_status = 'publish')
ORDER BY dev_posts.post_title LIKE '%test%' DESC, dev_posts.post_date DESC LIMIT 0,10
You could filter the WHERE
clause with the posts_search
filter but MySQL's REGEX
is very limited. I doubt you will be able to get it to ignore markup.
If I were facing this problem, I would parse the post on save-- save_post
or draft_to_publish
for example-- and store a keyword list to the database, then use the posts_search
filter, and/or other filters, to alter the search so that it searches the keyword list. Implementation can be more or less complicated depending on how you do it, but I think that is about the only way you are going to get the results you want without having to depend on MySQL extensions or external search engines like Sphinx.