• andyt1980

    (@andyt1980)


    Hi, Firstly, thanks for creating this plugin.

    We have an issue with the relevancy of the search results for certain keywords. For example ‘jug’ is showing spare parts for ‘jug’ at the top fo the search results with actual ‘jug’ products further down the search results. We have titles set to 10 in the weights setting. Synonyms can’t be used in this case because ‘jug’ is the correct term.

    I thought of may be trying to reorder the search results so that the category of spares products are always shown at the bottom of the search results. The problem there is, if someone wants to actually find a ‘jug’ spare part they will have to go through pages of search results to find them as there are over 40000 products on the site. So ideally we only want to reorder the results if the term ‘jug’ is used but when the term ‘jug spare part’ or ‘jug xxxxxx’ is used the results would be ordered normally.

    Would prefer not to post the URL to the site in public so can send you that privately if required.

    Thanks,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    There are several solutions to this. With Relevanssi Premium, I’d simply pin the main products for the word “jug”. That would ensure they’re always first in the results.

    Even without Premium, you can create a filter function that boosts the non-part results. I assume there’s a way you can tell apart which products are spare parts and which are the main products. A simple boost filter that gives a 100x boost for the main products should probably do the trick.

    The correct filter hook is relevanssi_results.

    Thread Starter andyt1980

    (@andyt1980)

    Thank you, that sounds promising.

    The main ‘jug’ products are in various different categories, however, all the spares are in the category /product-category/catering-appliances/spares-and-accessories/
    Therefore could all the main ‘jug’ products be boosted based on not being in /product-category/catering-appliances/spares-and-accessories/

    And if so, what would the code look like?

    Also, when reading through the documentation and supporting links for the filter hook it recommends running the search with the admin search tool. When I do this the relevancy of the results is more accurate. Does this mean the theme or plugin is altering the results ordering on the front-end?.
    Is there some way I can identify what is altering the ordering?

    • This reply was modified 2 months ago by andyt1980.
    Plugin Author Mikko Saari

    (@msaari)

    If the results are really bad, it’s likely they’re not sorted by relevance. This is controlled by the orderby parameter. You can fix it with this little snippet:

    add_filter( 'relevanssi_modify_wp_query', function( $query ) {
    $query->set( 'orderby', array( 'relevance' => 'desc' ) );
    return $query;
    } );

    Add this to your theme functions.php or in a code snippet.

    If this doesn’t help, we can add the boost function. For that, I need to know the ID number of the spare part category.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.