[wp-trac] [WordPress Trac] #7394: Search: order results by relevance
WordPress Trac
wp-trac at lists.automattic.com
Sat Aug 25 02:45:54 UTC 2012
#7394: Search: order results by relevance
-------------------------+-----------------------------
Reporter: markjaquith | Owner:
Type: enhancement | Status: assigned
Priority: normal | Milestone: Future Release
Component: General | Version: 2.6
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+-----------------------------
Comment (by azaozz):
Replying to [comment:20 tomauger]:
> Well, it appears that using REGEXP is significantly slower...
> However, one takeaway from the SQL below is that we might want to be a
bit more careful around word boundaries...
Yes, same as in my tests. Using REGEXP makes the search more precise but
is quite slower. On the other hand it almost doesn't affect the highest
relevance, full string match in titles. Also when using REGEXP the whole
set goes through all sorting rules. When using CASE with multiple WHEN ...
THEN it acts like a if()... elseif() block in PHP.
Adding sorting to the search query will slow it down in any case. Thinking
best would be to try to get the "most bang for the buck", i.e. something
like:
- full string in title,
- all words in title,
- any word in title,
- full string in content,
- everything else.
Assuming that most searches are for posts by title, and that 'all words'
and 'any word' matches in title would also match in the content.
Of course that makes the sorting less precise but keeps it very fast and
is a huge improvement over the current search.
> Note that I'm unsure as to the weighting of the same search sequence
within post_content as post_title. We may decide that two search terms
with proper word boundaries in the title is still better than the full
match in the content.
Yes, thinking that too. Seems best to make all matches in titles better
than a match in content.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/7394#comment:21>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list