Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

Relevance decreased after using relevanssi_comparison_order

$
0
0

Replies: 0

Hi. To improve my site search, I used the filter hook relevanssi_comparison_order. Here’s the code I added to the site:

add_filter( 'relevanssi_comparison_order', 'rlv_post_type_order' );
function rlv_post_type_order( $order ) {
  $order = array(
    'post' => 0,
    'page' => 1,
  );
  return $order;
};

add_filter( 'relevanssi_modify_wp_query', 'rlv_orderby' );
function rlv_orderby( $query ) {
    $query->set( 'orderby', 'post_type' );
    return $query;
}

However, after that the relevance of the search decreased. For example, I set the weight of the Titles element to 10000, but not all pages with the word X in the Title are at the top when searching for word X. Sometimes even pages without the word X in the Title are higher than the pages with X in Title.

I guess the goal is to have two levels of sorting, first – pages above posts (or vice versa), then relevance (not forgetting about the weight of the Title element). Can you help with that?

Thank you!


Viewing all articles
Browse latest Browse all 59525

Trending Articles