Skip to content

Commit

Permalink
Add Search Relevance changes that were not included in previous commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickebates committed Jan 30, 2014
1 parent f07d091 commit b2f00b1
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions wp-includes/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -2074,21 +2074,17 @@ protected function parse_search_order( &$q ) {
$search_orderby .= "WHEN PATINDEX('%{$search_orderby_s}%', $wpdb->posts.post_title) > 0 THEN 1 ";

$title_weight = " WHEN ";
$content_weight = " WHEN ";

foreach ( $q['search_terms'] as $term ) {
$term = like_escape( esc_sql( $term ) );
$title_weight .= "PATINDEX('%$term%', $wpdb->posts.post_title) + ";
$content_weight .= "PATINDEX('%$term%', $wpdb->posts.post_content) + ";
}
$title_weight .= "0 > 0 THEN 2";
$content_weight .= "0 > 0 THEN 4";

$search_orderby .= $title_weight;
// sentence match in 'post_content'
$search_orderby .= " WHEN PATINDEX('%{$search_orderby_s}%', $wpdb->posts.post_content) > 0 THEN 3 ";
$search_orderby .= $content_weight;
$search_orderby .= ' ELSE 5 END)';
$search_orderby .= ' ELSE 4 END)';
} else {
// single word or sentence search
$search_orderby = reset( $q['search_orderby_title'] ) . ' DESC';
Expand Down

0 comments on commit b2f00b1

Please sign in to comment.