Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #27531

    I was having a problem with search results prioritizing content over titles, so I installed Relevanssi and it fixed the issue. The problem I’m having now is that it only fixed the issue in the search results, but the instant search is unchanged.

    Is there a way to make these match up? Or can you point me in the direction of where instant search is pulling its search data?

    Here’s an example of what’s happening: https://www.evernote.com/shard/s260/sh/11f263db-26cf-4c58-b252-4ba2e5914440/469714435e9de6c91a59b1ee57f13050

    #134316

    Hey!

    The ajax search is powered by the avia_ajax_search function in functions-enfold.php

    The function has several filters that makes customization of the search parameters easy, but I am not sure if it will be enough for Relevanssi to hook into it.

    #134317

    Is there a simple way to edit the PHP in order to prioritize the page/blog names over the page content?

    #134318

    Hi rapinion,

    Not that I know of no. The theme is just using the WordPress query which you can read a bit more about here: https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter

    Regards,

    Devin

    #134319

    in relevanssi you can change the weighing of the POST/PAGE/TAXAMONY etc i think.

    it would be nice when the ajax search uses the relavanssi query.

    mAqq

    #134320

    You can use Relevanssi for the ajax search query. Open up enfoldfunctions-enfold.php and replace

    $defaults = array('numberposts' => 5, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false);
    $_REQUEST['s'] = apply_filters( 'get_search_query', $_REQUEST['s']);

    $query = array_merge($defaults, $_REQUEST);
    $query = apply_filters('avf_ajax_search_query', http_build_query($query) );
    $posts = get_posts( $query );

    with

    $defaults = array('numberposts' => 5, 'post_type' => 'any', 'post_status' => 'publish', 'post_password' => '', 'suppress_filters' => false);
    $_REQUEST['s'] = apply_filters( 'get_search_query', $_REQUEST['s']);

    $searchquery = array_merge($defaults, $_REQUEST);

    if(!function_exists('relevanssi_do_query'))
    {
    $searchquery = apply_filters('avf_ajax_search_query', http_build_query($searchquery));
    $posts = get_posts($searchquery);
    }
    else
    {
    global $query;
    $tempquery = $query;
    $searchquery = apply_filters('avf_ajax_search_query', $searchquery);

    $tempquery->query_vars = $searchquery;
    relevanssi_do_query($tempquery);
    $posts = $tempquery->posts;
    }

    #134321

    Works absolutely perfect, just tested it. Thanks, Dude!

    #134322

    We added a filter to the theme. In the next version you’ll be able to include this code without modifying the function (eg you can use a child theme then). I’ll post the code here when we released the update.

    Update – with the next version following code should be used instead

    add_filter('avf_ajax_search_function', 'avia_init_relevanssi', 10, 4);
    function avia_init_relevanssi($function_name, $search_query, $search_parameters, $defaults)
    {
    $function_name = 'avia_relevanssi_search';
    return $function_name;
    }

    function avia_relevanssi_search($search_query, $search_parameters, $defaults)
    {
    global $query;
    $tempquery = $query;

    $tempquery->query_vars = $search_parameters;
    relevanssi_do_query($tempquery);
    $posts = $tempquery->posts;

    return $posts;
    }

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Instant search not matching search results’ is closed to new replies.