• Resolved dopkarolina

    (@dopkarolina)


    When you type in the phrase “frez cb033”, a lot of search results are displayed that only match the phrase “frez”.

    But the product “MANI KING Frez ceramiczny CB033 – walec, XF” (that is, the only one that matches both words) is displayed only on the third page.

    Is it possible to solve this problem so that the matching product (the only one) displays at the top of the search results?

    (Site in Polish)

    I used the code below and did a reindex, but it did not help:

    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;
    
    }
    • This topic was modified 2 years, 7 months ago by dopkarolina.
    • This topic was modified 2 years, 7 months ago by dopkarolina.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    The code that you mentioned is only for full phrases match. In your case there are two words inside the title. So please try to use this code instead:

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

    Regards

    Thread Starter dopkarolina

    (@dopkarolina)

    Thank you for your answer, but that unfortunately did not help (I reindexed the products again). The target product is still on page three.

    https://maniking.pl/?s=frez+cb033&post_type=product&type_aws=true

    • This reply was modified 2 years, 6 months ago by dopkarolina.
    Plugin Author ILLID

    (@mihail-barinov)

    Please try this code snippet instead of previous one:

    add_filter( 'aws_relevance_parameters', 'my_aws_relevance_parameters' );
    function my_aws_relevance_parameters( $relevance_params ) {
        $relevance_params['title']['full'] = 1000;
        $relevance_params['title']['like'] = 400;
        $relevance_params['content']['full'] = 100;
        $relevance_params['content']['like'] = 20;
        return $relevance_params;
    }
Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Search Result Issue’ is closed to new replies.