• Resolved jayford

    (@jayford)


    Hi,

    Thank you so much for your great plugin. This plugin really help and nearly finish my website.

    I have one more problem regarding with the search results of my website.
    I’m running a website which search dates converted to corresponding serial number in money. (datesonnotes.com). It fetch results with this format ddmmyy and ddmmyyyy but when the user enter this kind of format dd/mm/yy or dd-mm-yy and dd.mm.yy it doesn’t return any results wen I already have put this all formats in my post_content.

    My point is that it will accept the user input with those kind of formats.

    Please help me.
    Thanks

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

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

    (@msaari)

    Relevanssi removes punctuation, so that breaks all the date formatting that has punctuation in it. I would suggest converting all user-entered dates to ddmmyy or ddmmyyyy format.

    add_filter('relevanssi_remove_punctuation', 'rlv_convert_dates', 9);
    function rlv_convert_dates($a) {
        $a = preg_replace('/(\d\d)\/(\d\d)\/(\d\d\d\d)/', '\1\2\3', $a);
        $a = preg_replace('/(\d\d)\/(\d\d)\/(\d\d)/', '\1\2\3', $a);
        $a = preg_replace('/(\d\d)\.(\d\d)\.(\d\d\d\d)/', '\1\2\3', $a);
        $a = preg_replace('/(\d\d)\.(\d\d)\.(\d\d)/', '\1\2\3', $a);
        $a = preg_replace('/(\d\d)-(\d\d)-(\d\d\d\d)/', '\1\2\3', $a);
        $a = preg_replace('/(\d\d)-(\d\d)-(\d\d)/', '\1\2\3', $a);
        return $a;
    }

    Something like that.

    Thread Starter jayford

    (@jayford)

    Hi Mikko,

    Thank you so much for your kind response.

    I also do like this one base on what I read on your webssite https://www.relevanssi.com/knowledge-base/words-ampersands-cant-found/

    such a great plugin Mikko.

    add_filter('relevanssi_remove_punctuation', 
    
    'saveampersands_1', 9);
    function saveampersands_1($a) {
    $a = str_replace('/', 'HYPHEN', $a);
    $a = str_replace('-', 'HYPHEN', $a);
    $a = str_replace('.', 'HYPHEN', $a);
    return $a;
    }
    
    add_filter('relevanssi_remove_punctuation', 
    
    'saveampersands_2', 11);
    function saveampersands_2($a) {
    $a = str_replace('HYPHEN', '/',  $a);
    $a = str_replace('HYPHEN', '-',  $a);
    $a = str_replace('HYPHEN', '.',  $a);
    return $a;
    }
    Plugin Author Mikko Saari

    (@msaari)

    That doesn’t work the way you want – it changes slashes, hyphens and periods to HYPHEN, and then changes HYPHEN to slash. So, all slashes, hyphens and periods (including those that end sentences!) become slashes.

    If you want to go that way, then you can keep slashes, hyphens and periods that are between two digits, but it’s better if you remove that and use the code I gave you to normalize all different date formats to single style.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Search format not showing results’ is closed to new replies.