• This has worried me for quite a while so let me ask. Why would you show the exact string I am searching for further down in the results? Why is it not the first result. See here: https://snipboard.io/8dfVcS.jpg. This happens on basically all searches I do.

    The page I need help with: [log in to see the link]

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    So speaking about your example – looks like searching words appears not only product title, but inside product content. And inside the content it repeats several times. That is why the products with not fully matched title appear higher in the search results.

    But it is something that can be fixed with some code snippets. The trick is to add a higher relevance score for words inside the product title. Please use code:

    add_filter('aws_relevance_scores', 'my_aws_relevance_scores');
    function my_aws_relevance_scores( $relevance_array ) {
        $relevance_array['title'] = 600;
        return $relevance_array;
    }

    You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.

    Also, after adding this code you will need to go to the plugin settings page and click the ‘Clear cache’ button.

    Regards

    Thread Starter Dumel

    (@dumel)

    Thanks, I tried the code to a snippet that runs everywhere but it seems worse to me. I used the same example as before (apologies for the music): https://www.loom.com/share/261cb35d75b54de2914450be21372425

    Plugin Author ILLID

    (@mihail-barinov)

    I see. So did you clear the plugin cache after adding this code snippet?

    Regards

    Thread Starter Dumel

    (@dumel)

    Yes I did ??

    Plugin Author ILLID

    (@mihail-barinov)

    Ok. I understand. In this case please try following additional code snippets:

    add_filter( 'aws_indexed_data', 'my_aws_indexed_data', 10, 2 );
    function my_aws_indexed_data( $data, $id ) {
        $data['terms']['full_title'][get_the_title( $id )] = 1;
        return $data;
    }
    
    add_filter( 'aws_search_query_array', 'my_aws_search_query_array' );
    function my_aws_search_query_array( $query ) {
        $relevance = '';
        $term = esc_attr( $_REQUEST['keyword'] );
        $term = htmlspecialchars_decode( $term );
        $term = AWS_Helpers::normalize_string( $term );
        if ( $term ) {
            $relevance .= "( case when ( term_source = 'full_title' AND term LIKE '%{$term}%' ) then 800 else 0 end ) + ";
            $query['relevance'] = preg_replace( '/\(SUM\([\s\S]*?\([\s\S]*?case[\s\S]*?end[\s\S]*?\)[\s\S]*?\+/i', '$0' . $relevance, $query['relevance'] );
        }
        return $query;
    }

    Please reindex plugin table after adding this code.

    Regards

    Thread Starter Dumel

    (@dumel)

    Still the same situation unfortunately. When I search for the product called “BeSafe iZi Turn B i-Size” then the actual product with that exact name is only listed as the 9th result.

    I’m not sure if this helps, but I have the same issue and would love for the title to be more weighted. I installed the first clip which didn’t help really. Then installed the second clip. Cleared cache. Reindexed table and it was the same search result.

    The 2.74 update seems to have fixed the Weighted titles for my site.

    Thread Starter Dumel

    (@dumel)

    I disabled the code widgets you gave me and updated to version 2.74, reindexed the tables and cleared the cache. I still get the same issue.

    Dumel – I upgraded, enabled the 2nd code posted. Cleared cache, re-indexed.

    I apologize, I guess I needed to test further. Although it worked perfectly for one search (King Gizzard), it still puts another 3 pages deep in the results (Love and Rockets).

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Search results could be more accurate’ is closed to new replies.