[wp-trac] [WordPress Trac] #21638: Improve searching through posts
WordPress Trac
wp-trac at lists.automattic.com
Mon Aug 20 01:19:51 UTC 2012
#21638: Improve searching through posts
-------------------------+------------------------------
Reporter: azaozz | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+------------------------------
Comment (by azaozz):
If we go with showing the 'title' matches before the 'content' matches,
been testing something like this for the search query:
{{{
( SELECT * FROM wp_posts WHERE post_title LIKE '%searchterm%' AND ... )
UNION
( SELECT * FROM wp_posts WHERE post_content LIKE '%searchterm%' AND ... )
LIMIT 0, 20
}}}
This returns the posts whose titles match "searchterm" before the posts
whose content matches it. Using `UNION` makes the set unique (no need for
DISTINCT).
Seems to be a little bit slower than the current `WHERE post_title LIKE
'%searchterm%' OR post_content LIKE '%searchterm%'` as UNION always
creates temp table. On the other hand the search sorting can be enhanced
by creating the temp table by hand, filling it with couple of SELECTs and
then running another select with additional sorting, etc.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21638#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list