• Resolved thkost

    (@thkost)


    Hello, I have a woocommerce website and there is a problem with the search results.

    I have products that have the product code on the title (example CE278A), when I search as 278 (/?s=278) it doesn’t show up, but if search it like this (/?s=278a) the product in question shows up.

    Any clues why?

    • This topic was modified 6 years, 8 months ago by thkost.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Because Relevanssi doesn’t match inside strings, only beginnings and ends. So “ce2” works, “78a” works, but “278” doesn’t.

    If you want to enable inside-word matching (and be warned, it’ll lead to an increased amount of garbage results), click “Help” on the top right corner of the Relevanssi settings pages in your admin dashboard and see the instructions under “Searching”.

    Thread Starter thkost

    (@thkost)

    Hello again,

    I added this:

    add_filter( ‘relevanssi_fuzzy_query’, ‘rlv_partial_inside_words’ );
    function rlv_partial_inside_words( $query ) {
    return “(term LIKE ‘%#term#%’)”;
    }

    but it didn’t make any differrence

    Plugin Author Mikko Saari

    (@msaari)

    What is your setting for “Keyword matching” in Relevanssi searching settings? Does setting that to “Whole words” make any difference?

    If it doesn’t, next step is to make sure your site is actually using Relevanssi to provide the results. If you completely disable Relevanssi, do the results change?

    Thread Starter thkost

    (@thkost)

    Changed it but didn’t see any differences.

    If i deactivate Relevanssi it does work with the default search.

    But i want to use Relevanssi because i am also using this:

    add_filter(‘relevanssi_remove_punctuation’, ‘remove_hyphens’, 9);
    function remove_hyphens($a) {
    $a = str_replace(‘-‘, ”, $a);
    return $a;
    }

    which does work.

    Plugin Author Mikko Saari

    (@msaari)

    You should have “Keyword Matching” set to “Partial” for this to work, so if you had something else in the setting, then it won’t work.

    Other than that, I don’t know. You can try this in your theme functions.php:

    add_filter( 'relevanssi_query_filter', 'rlv_check_mysql' );
    function rlv_check_mysql( $query ) {
        var_dump( $query );
        exit();
    }

    What does this print out when you do a search?

    Thread Starter thkost

    (@thkost)

    It prints

    string(816) "SELECT DISTINCT(relevanssi.doc), relevanssi.*, relevanssi.title * 2 + relevanssi.content * 1 + relevanssi.comment * 0 + relevanssi.tag * 0.75 + relevanssi.link * 0 + relevanssi.author + relevanssi.category * 1 + relevanssi.excerpt + relevanssi.taxonomy + relevanssi.customfield + relevanssi.mysqlcolumn AS tf FROM u0rz_relevanssi AS relevanssi WHERE (term LIKE '%278%') AND ((relevanssi.doc IN (SELECT DISTINCT(posts.ID) FROM u0rz_posts AS posts WHERE posts.post_type NOT IN ('revision', 'nav_menu_item', 'custom_css', 'customize_changeset', 'oembed_cache', 'user_request', 'wc_category_slider', 'acf-field-group', 'acf-field', 'product_variation', 'shop_order', 'shop_order_refund', 'shop_coupon', 'wpcf7_contact_form', 'import_users', 'wysijap'))) OR (doc = -1)) ORDER BY tf DESC LIMIT 500"

    • This reply was modified 6 years, 8 months ago by thkost.
    Plugin Author Mikko Saari

    (@msaari)

    Everything seems to be working correctly. I don’t know why it’s not making any difference in the results, this should match CE278A.

    Thread Starter thkost

    (@thkost)

    Well after I removed var_dump it started working correctly, I am not really sure how and why. Thanks for your time!

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