• Resolved cheyenne711

    (@cheyenne711)


    Hi,

    I am having trouble getting the most relevant products when I do search results. For example if I put in “wire nuts” the only product labeled wire nuts shows way down in the search results. Could you please help me with this. Thank you.

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

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

    (@mihail-barinov)

    Hi,

    What you can do here is to add more weight for words inside product title.

    Please try following code snippet:

    add_filter( 'aws_relevance_scores', 'my_aws_relevance_scores' );
    function my_aws_relevance_scores( $relevance_array ) {
        $relevance_array['title'] = 900;
        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 cheyenne711

    (@cheyenne711)

    Thanks but that didn’t work. Are there some other settings that might need to be changed? When I disable the plugin, the standard WordPress search gives the correct results.

    Thread Starter cheyenne711

    (@cheyenne711)

    Is there a way to just use the standard WordPress search results? The AWS plugin is great for showing displaying the results in the search bar but almost none of the search results have been relevant.

    Thanks

    Plugin Author ILLID

    (@mihail-barinov)

    Do you mean – show standard WordPress search results inside AWS plugin search bar? If so – then I’m afraid that it is not possible.

    Thread Starter cheyenne711

    (@cheyenne711)

    Okay, could you please let me know what settings I can change then to get more relevant results to show.

    Plugin Author ILLID

    (@mihail-barinov)

    So, if we are speaking about relevance for words inside the product title, then you can try the code snippet that I provided previously.

    Make sure that after adding it you access the plugin settings page -> Performance tab and click the ‘Clear cache’ button.

    Also inside this code snippet you can change 900 value to something even bigger.

    Thread Starter cheyenne711

    (@cheyenne711)

    Hi Illid,

    So the title relevance still doesn’t seem to help. For example when putting “bushings” in the search. The correct results come up. However when I put in “Stainless Steel Bushings” everything stainless steel comes up and the bushings are buried in the results. Can you please let me know how I can have it match the search words (phrase) together instead of each word independently? Thanks.

    Plugin Author ILLID

    (@mihail-barinov)

    Additionally please try to use the following code snippet:

    class AWS_Relevance_Update {
        public $terms = array();
        public function __construct() {
            add_filter( 'aws_indexed_data', array( $this, 'aws_indexed_data' ), 10, 2 );
            add_filter( 'aws_search_terms', array( $this, 'aws_search_terms' ), 10, 2 );
            add_filter( 'aws_search_query_array', array( $this, 'aws_search_query_array' ) );
        }
        function aws_indexed_data( $data, $id ) {
            $data['terms']['full_title'][get_the_title( $id )] = 1;
            return $data;
        }
        function aws_search_terms( $terms ) {
            $this->terms = $terms;
            return $terms;
        }
        function aws_search_query_array( $query ) {
            global $wpdb;
            if ( $this->terms  ) {
                $terms = '';
                foreach( $this->terms as $term ) {
                    $like = '%' . $wpdb->esc_like( $term ) . '%';
                    $terms .= $wpdb->prepare( 'AND term LIKE %s', $like );
                }
                $relevance = "( case when ( term_source = 'full_title' {$terms} ) then 1000 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;
        }
    }
    new AWS_Relevance_Update();

    After adding it you need to reindex plugin table.

    Regards

    Thread Starter cheyenne711

    (@cheyenne711)

    Unfortunately that didn’t work. I am still seeing completely irrelevant results. Is there something else I can try? When I search for “wire nuts” an unrelated bolt and assortment are the first things that come up. If I disable the AWS plugin then the “Wire Nuts” and wire nut assortment appear first.

    https://eeinc.biz/?s=wire+nuts&post_type=product&type_aws=true

    Thread Starter cheyenne711

    (@cheyenne711)

    I figured out what is causing the issue. The Woo Commerce product filter plugin I am using is interfering with the search results. Do you have a way to avoid this conflict?

    Plugin Author ILLID

    (@mihail-barinov)

    Can you please give me a link to this plugin? I will see what can be done here.

    Regards

    Thread Starter cheyenne711

    (@cheyenne711)

    Here is the link. Thank you so much! https://woobewoo.com/plugins/woocommerce-filter/

    Plugin Author ILLID

    (@mihail-barinov)

    So I looked at this plugin and found that they built a special code to create integration with the Advanced Woo Search plugin. But it looks like this code is not working as expected.

    Please tell me – do you have their paid plugin version and have access to their support? Looks like you need to create a support ticket for them with this issue explanation. I can help you with the description of that problem and how it can be solved from their side.

    Regards

    Thread Starter cheyenne711

    (@cheyenne711)

    I was able to deactivate the search settings on the other plugin and that resolved the issue. Thank you so much for your help!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Most Relevant Products not Showing’ is closed to new replies.