• Resolved samueljeden

    (@samueljeden)


    Hi Mikko,

    Im having a real problem searching for numbers inside a a product field.

    my example is

    https://www.maes-group.co.uk/shop/lucas/iveco-ford-cargo-12-volt-10-tooth-starter-motor/

    You can see here in the additional information tab that there are a list of cross reference numbers.

    in this list any long number works perfect, but short 5 digit numbers do not.

    IE

    if you use the search box at the top (for products only) and search:
    0986012470 it links directly back to the product.

    HOWEVER
    if you search 26341 – this does not work. it is the same on all of my products.

    NOW

    if you have a number with a letter at the end ie 25605D
    if you search 25605 it works how it should but if you search 25524 it doesn’t work. (which is in the same list as 25605)
    IM REALLY CONFUSED. I HAVE JUST UPDATED TO 3.6 and i think everything was working right before.

    PLEASE HELPP!!!!

    Thanks
    Samuel@MAES

    https://www.ads-software.com/plugins/relevanssi/

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Author Mikko Saari

    (@msaari)

    What is your minimum word length setting in Relevanssi settings? Could it be six?

    Thread Starter samueljeden

    (@samueljeden)

    Minimum word length is 2.

    Plugin Author Mikko Saari

    (@msaari)

    Well, I have to say I don’t know, not without looking under the hood. Have you tried re-indexing the database and deactivating and reactivating the plugin?

    Thread Starter samueljeden

    (@samueljeden)

    Hey Mikko,

    yes, ive tried both those things – its a strange occurance.

    as far as im aware it worked flawlessly before i updated wordpress to 3.6 – but that was only in tests.

    it was only brought to my attention when someone in the shop front tried using the website for a product that indeed we did sell but could not be located by its 5 digit reference :/

    do you want any details for login? i remember that you looked at my site for woocommerce issues before.

    Thread Starter samueljeden

    (@samueljeden)

    i can confirm this number 26341 is in the postmeta table too. i have checked via phpmyadmin for this to make sure it is being saved correctly.

    Plugin Author Mikko Saari

    (@msaari)

    You can check the _relevanssi table as well – does the number appear there in the “term” column?

    You can send me the logins to mikko @ mikkosaari.fi.

    Thread Starter samueljeden

    (@samueljeden)

    Hey Mikko,

    there is no record of the 26341 word in the _relevanssi table.

    Plugin Author Mikko Saari

    (@msaari)

    Looks like there’s a bug in Relevanssi in how numeric search terms are handled. Next version will fix that.

    Hi Mikko,

    I’m facing exactly the same problem.
    1-Do you have an update on the problem?
    2-Do you need a hand?
    3-Where should I look?

    My bad, all is good.

    Mikko, I love your plugin.

    Same problem here, but then with version numbers. So searching for i.e. “WordPress+3.7” would ignore “3.7”. Especially on technical websites this is a problem.

    Thanks for the great plugin! I love it.

    I solved it in common.php

    Replace

    $a = preg_replace('/([[:punct:]])+/u', ' ', $a);

    with

    $a = preg_replace('/((?!(\.\d))[[:punct:]])+/u', ' ', $a);

    This leaves numbers like “.55” and “3.7” in the index, while before they were changed to “55” and “3 7”

    Hope this helps others too.

    Plugin Author Mikko Saari

    (@msaari)

    Changing the default function is a bad idea, as your changes will be then overwritten when Relevanssi is updated. Instead, make a copy of the relevanssi_remove_punct() function, call it something else (say vinx77_remove_punct()), make changes there and then add this:

    remove_filter('relevanssi_remove_punctuation', 'relevanssi_remove_punct');
    add_filter('relevanssi_remove_punctuation', 'vinx77_remove_punct');

    This function is designed to be replaced with another function if necessary, so there’s no reason to change the function in common.php.

    vinx77

    (@vinx77)

    Thanks Mikko for the suggestion, as indeed I need to edit with every update. ?? I’d prefer if you could add an option for indexing numbers, of course.

    Now got below code, but doesn’t work if I put it in my template’s functions.php – rebuilding the index doesn’t work (0 documents in the index). Where should I put it? Or what should I do different?

    function relevanssi_remove_punct_not_numbers() {
    	$a = strip_tags($a);
    	$a = stripslashes($a);
    
    	$a = str_replace("·", '', $a);
    	$a = str_replace("…", '', $a);
    	$a = str_replace("€", '', $a);
    	$a = str_replace("­", '', $a);
    	$a = str_replace(chr(194) . chr(160), ' ', $a);
    	$a = str_replace(" ", ' ', $a);
    	$a = str_replace('’', ' ', $a);
    	$a = str_replace("'", ' ', $a);
    	$a = str_replace("’", ' ', $a);
    	$a = str_replace("‘", ' ', $a);
    	$a = str_replace("”", ' ', $a);
    	$a = str_replace("“", ' ', $a);
    	$a = str_replace("?", ' ', $a);
    	$a = str_replace("′", ' ', $a);
    	$a = str_replace("—", ' ', $a);
    	$a = str_replace("–", ' ', $a);
    	$a = str_replace("×", ' ', $a);
    
            $a = preg_replace('/((?!(\.\d)):punct:)+/u', ' ', $a);
    	//$a = preg_replace('/:punct:+/u', ' ', $a);
            $a = preg_replace('/:space:+/', ' ', $a);
    	$a = trim($a);
    
            return $a;
    }
    
    if ( function_exists( 'relevanssi_remove_punct' ) ) {
    
    	remove_filter('relevanssi_remove_punctuation', 'relevanssi_remove_punct');
    	add_filter('relevanssi_remove_punctuation', 'relevanssi_remove_punct_not_numbers');
    
    }
    Plugin Author Mikko Saari

    (@msaari)

    Your function is missing the argument, it should be

    function relevanssi_remove_punct_not_numbers($a) {

    Otherwise it seems correct to me.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Relevanssi and numbers.’ is closed to new replies.