Support » Plugin: Relevanssi - A Better Search » Exact results are not first

  • Hello Mikko,

    Thanks for your great plugin.

    For about two days I’m trying to boost exact title matches (https://www.relevanssi.com/knowledge-base/adding-extra-boost-exact-title-matches) but it looks it’s not working for me. There is no change when I add it to functions.php

    Here are my not-so-ideal results:

    https://picjumbo.com/?s=car
    » displaying credit cards first instead of photos with “Car” in title

    https://picjumbo.com/?s=bra
    » displaying Braies Lake in Italy first instead of photos with “Bra” in title.

    I understand why these results are there (there are more “card” tags than “car” tags) but I cannot force Relevanssi to show exact terms on top with your code.

    The only change in results was when I changed your line

    if (stristr($post->post_title, $query) != false) $results[$post_id] = $weight * 100;

    to

    if (stristr($post->post_title, $query) != false) $results[$post_id] = 650000000000000000000000000000000000000000000000000000000000;

    (even $weight*650000000000000… = no change)

    Then “car” titles were boosted and some of them are on first positions, but in “bra” search the first post is still Braies Lake and Zebra.

    I also tried your code with exact matches on top (https://gist.github.com/msaari/45881fa538ef0087a01996aabfbe88a4#file-relevanssi-exact-title-match-php). Again, no luck, no change.

    Or did I understand it wrong and all this is for matching word combinations?

    ————————

    Settings

    Content 2
    Titles 3
    Comment text 0.75
    Tag weight 3
    Category weight 0.75

    — OR
    — Relevance
    — Partial words
    — Boost to exact matches

    The page I need help with: [log in to see the link]

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

    (@msaari)

    The first step in debugging weighting problems is to try the Relevanssi admin search (Dashboard > Admin search). It will show you the relevance scores of the posts, so you can see the exact effects of your adjustments.

    But the thing here is that the exact match bonus doesn’t help you out with this. It’s only useful for multiple word combinations. “Braies Lake” is an exact match for “bra”, because Relevanssi makes a simple string comparison and sees that “bra” appears in the post title, so it’s a match.

    The exact title matches to the top of the results code doesn’t help either, because it’s too strict: it would lift a post with a title of “Bra” to the top of the results, but nothing else.

    I generally don’t recommend it, but in your case the Keyword matching setting of “Partial words, if no whole word matches are found” might be useful. I think stock photo searches are generally short, single keyword searches, where that setting would work quite well.

    (That mega boost you have there is, by the way, bigger than the maximum integer size in PHP, which may lead to funny results. The biggest integer PHP can handle is PHP_INT_MAX, which is generally surprisingly small 9223372036854775807.)

    For boosting exact title matches try this plugin Search title boost plugin

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.