search on multisite

This topic contains 3 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 9 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #34149
    figmints19
    figmints19
    Participant

    I purchased this plugin so that I can use the search across a multisite environment however when I search within the multisites it does not combine the results based on relevance, For instance if i search for “CIM” I will mainly get results from the main site with CIM in the wording however their is a subsite dedicated to CIM that would have more relevant results. Those results will only display after every initial main site results has displayed. I was expecting them to be combined based on relevance no matter the site they belonged to. Is there a setting that can be toggled to manage this?

    The search is on the right side of the header in the main site

    Thanks

    #34156
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    Thank you for the details.

    It should be the case by default, I guess there is some sort of an exception, which does not trigger the re-sorting of the results after all of them are fetched.

    I can suggest a custom code to get around this, it is probably the best and fastest possible solution.

    function asp_compare_by_relevance( $a, $b ) {
    	return $b->relevance - $a->relevance;
    }
    
    add_filter( 'asp_results', 'asp_reorder_results_by_relevance', 10, 1 );
    function asp_reorder_results_by_relevance( $results ) {
    	usort($results, 'asp_compare_by_relevance');
    	return $results;
    }

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    Let me know, if this changes anything. Thank you!

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #34274
    figmints19
    figmints19
    Participant
    You cannot access this content.
    #34275
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    I tried to check, but the plugin is currently deactivated: https://i.imgur.com/k0FrSRq.png
    Can you please also add temporary FTP access? I will try to debug the search code to see what is going on.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.