• This might be implemented by stuff in the Knowledge Base but I feel it should be included in the core features.

    I would like to have the keyword matching set as partial words but have the whole words first show up first, then after them a text “partial word results: and then the partial word results.

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

    (@msaari)

    You can add this to your site to get whole word matches to rank higher than the partial word matches:

    add_filter( 'relevanssi_match', 'rlv_prefer_whole_words', 10, 3 );
    function rlv_prefer_whole_words( $match, $idf, $term ) {
        if ( $match->term === $term ) {
            $match->weight *= 1000;
        }
        return $match;
    }

    However, you can’t tell where the whole word matches end and where the partial matches begin. I’m not sure if there’s a reasonable way to do that. It might be possible to do that; I’d need to think about it. Nobody has ever requested that before, and overall this is rarely enough wanted feature that this will not be a core feature in Relevanssi.

    Thread Starter cybnex

    (@cybnex)

    Some scenarios:

    Whole words enabled: A user searches for mason and gets 0 results. He is sad. However there would have been many relevant articles with the word masonry in them that he would have enjoyed. I’m sad.

    Would the solution have been to enable partial words? Well, perhaps with this word, however:

    Partial words enabled
    : A user searches for bar and gets a mishmash of words containing bar and has to fish out the relevant articles about Bar (law).

    Whole words with partials after A user search for bar gets 3 articles about The Finnish Bar Association (success) and one about a sports bar in Tammisaari (ignore). He scrolls down and sees the text “partial word results: and alot of barometric barracudas, barricades, toolbars, taskbars etc unrelated stuff and quickly realizes there’s nothing there of relevance for him…He’s happy

    • This reply was modified 2 years, 4 months ago by cybnex.
    • This reply was modified 2 years, 4 months ago by cybnex. Reason: carpenter->mason
    Plugin Author Mikko Saari

    (@msaari)

    Your initial example of carpenter vs carpentry was pretty good, actually. It shows that partial matching doesn’t solve everything. If that’s your problem, then the solution is a stemmer.

    In general, yes, what you’re saying makes sense. I think most users won’t need the heading; they’ll just look at the top results anyway. Few users bother scrolling far down. If you really want that heading, then you’d probably need to use a relevanssi_match filter function and mark each post that has an exact match. Then in a relevanssi_hits_filter hook, you can sort the posts so that those with an exact match come first and those without come later. Then you can look for where the break is and output the heading there in the search results template.

    Also, there’s no one size fits all solution for this. The needs for different sites and different languages aren’t the same. Some sites require exact matching; some sites require as wide recall as possible.

    One solution is to use whole word matching for short words and partial matching for longer words. This is described here.

    Thread Starter cybnex

    (@cybnex)

    Carpenter was a mistake. The real world example was in fact freemason that gave 0 results even though there were articles about freemasonry, but I changed that to carpentry without properly looking at the word.

    Stemmer, interdasting. Thanks. Looks like I’ll have to dive into your very thorough knowledge base, groan.

    Plugin Author Mikko Saari

    (@msaari)

    Stemmer solves the problem with mason vs masonry as well, as both become the same. You don’t have to use partial matching at that point.

    The Knowledge Base is a bit deep, but hey, I heard it has a pretty good search ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Partial word results listed after whole words’ is closed to new replies.