The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Relevanssi - A Better Search
[resolved] better relevance_score (3 posts)

  1. AliMH
    Posted 2 years ago #

    hey mikko,
    first really thanks for your plugins,it's awesome.
    my only remaining problem is relevance_score.
    if you check this link http://animup.net/?s=one+piece&post_types=animes&types=anime&orderby=relevance_score&order=DESC
    you can see that topic with exactly "One piece" in title come in 21's result. is there anyway to to make it first?


  2. Mikko Saari
    Plugin Author

    Posted 2 years ago #

    The problem is, nothing makes that post more valuable than the other posts above it, all of which mention "One piece" in the title as well. The one on top actualle mentions "One Piece" twice in the title, which makes it appear twice as significant.

    If you want to make exact match titles like this appear on top of the results, you need to force it. relevanssi_hits_filter gives you all the tools you need: it gives you an array of search results and the search term. You can go through the results and if the title matches exactly to the search term, move that post first in the results.

    There are some examples in the user manual.

  3. AliMH
    Posted 2 years ago #

    really thanks,
    here is my wroking code:

    function order_the_results($hits) {
        global $wp_query;
    	foreach ($hits[0] as $hit){
    		if ($search == strtolower($hit->post_title)){
    			array_unshift($hits[0] , $hit);
    	return $hits;

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Relevanssi - A Better Search
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.