• Resolved sebastian1234

    (@sebastian1234)


    Hi,

    Thank you for the nice plugin.

    I have enabled the “relevanssi_block_one_letter_searches” in the function.php. That works great. But is it possible with the “one letter search” that the search only find the posts with the first letter in the complete title? For example if I search for “F” it finds also “Brilliance of the Seas”, because of the “F” in “of”. But I only want that it shows me only titles with the first letter of “f” and “Brilliance of the Seas” only if I search for “B”.

    I hope you understand what I mean and there is a way for it.
    Thank you for help.

    Sebastian

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

    (@msaari)

    add_filter( 'relevanssi_fuzzy_query', 'rlv_partial_only_beginnings' );
    function rlv_partial_only_beginnings( $query ) {
    	return "(term LIKE '%#term')";
    }

    Adding this to theme functions.php will make Relevanssi only match the beginnings of the words –?but this applies to all search terms, not just one-letter words. There’s no easy way to make it apply to only one-letter search terms.

    Thread Starter sebastian1234

    (@sebastian1234)

    mhh thanks, but it has not worked. And somehow the search is broken now, also if I remove the code. But if you mean it is not possible to search just for the first letter of a sentence, I think we need an other solution.

    Plugin Author Mikko Saari

    (@msaari)

    This should work better:

    add_filter( 'relevanssi_fuzzy_query', 'rlv_partial_only_beginnings' );
    function rlv_partial_only_beginnings( $query ) {
    	return "(relevanssi.term LIKE '#term#%') ";
    }

    But yes, searching just for the first letter of a sentence in Relevanssi is going to be difficult, because it’s a very rare use scenario: you’re the first one to need that in the almost 10 years I’ve been doing Relevanssi =)

    Thread Starter sebastian1234

    (@sebastian1234)

    Hi Mikko,

    Sorry for the late answer, I was on holiday. Thanks for the try to help, badly it still not working. So if it too difficult to realise that in “Relevanssi” I think we have to find another way.

    Greetings
    Sebastian

    Plugin Author Mikko Saari

    (@msaari)

    Yes, it’s probably best to look for a different solution, this is something that won’t be easy in Relevanssi.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘One letter search – Find only the first letter’ is closed to new replies.