• Resolved israel5ew

    (@israel5ew)


    I have an issue with the search result.

    Upon typing in ‘Vitamin A’ the product Vitamin A is not on the top of the list. Here’s a screenshot:
    https://snipboard.io/SANcki.jpg

    I have already removed ‘a’ from the Stop Words List but the search result is not optimal.

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

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

    (@mihail-barinov)

    Hi,

    You can try to add following code snippet:

    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;
    }

    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 need to re-index the plugin table.

    Regards

    Thread Starter israel5ew

    (@israel5ew)

    It is works well.

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search Result Issue’ is closed to new replies.