• Resolved gusgianetti1997

    (@gusgianetti1997)


    Hello, I′m having two issues referred to the plugin:

    1: When you are searching a product, the list of products isn′t displayed.

    2: When you enter the search, with a keyword like “aire” the results aren′t precise. It would be nice that “Aire acondicionado MIDEA 2250 frigorías tipo ON/OFF” appears first.

    3: Another thing, is that is looking for post types, and not products.

    Thanks.

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

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

    (@mihail-barinov)

    Hi,

    1. Do you mean ajax live search results?
    2. So you want to add more score to products that have search words in the beginning of the title?
    3. Not understanding this point – I checked the search results page and I see products search results here. No other post types.

    Regards

    Thread Starter gusgianetti1997

    (@gusgianetti1997)

    1. Yes, that′s what i meant.
    2. Exactly. If i search “Aire”, the first result must be: “Aire acondicionado MIDEA 2250 frigorías tipo ON/OFF”.
    3. You are right, maybe, the problem is that my template doesn′t have css included (_underscore).

    Thanks for your reply, as always very precise.

    Plugin Author ILLID

    (@mihail-barinov)

    1. As I see, the plugin js file is not loaded on this page. Please tell me – are you using any caching or assets optimization plugins?
    2. Well, the plugin doesn’t look at the position of words when calculating each search result’s relevance score. But you can try to use the following code snippet:
    class AWS_First_title_word {
        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 ) {
            $relevance = '';
            if ( $this->terms  ) {
                foreach( $this->terms as $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;
        }
    }
    new AWS_First_title_word();
    
    

    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.

    3. Yes, I think the problem is in your theme template for products search results.

    Thread Starter gusgianetti1997

    (@gusgianetti1997)

    1. Nope, there is no optimization plugin activated.
    2. Sadly, adding that function to functions.php makes the same results. But I noticed one thing, when I use the original wordpress search bar it does work like I want. Have any solution to that?
    Plugin Author ILLID

    (@mihail-barinov)

    1. Do you have any ideas why plugin js files won’t load? Maybe you have some other plugins installed that can lead into this problem?

    2. Did you reindex the plugin table after adding this code?

    Thread Starter gusgianetti1997

    (@gusgianetti1997)

    I tweaked it a bit for best scoring when match keyword and works perfect. Just a reminder for everyone that is reading this, reindex table and then update, its not automatic.

    Thanks a lot for your helping.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Help with search result’ is closed to new replies.