Support » Plugin: Relevanssi - A Better Search » AND Operator not producing expected results

  • Hi,
    I am experiencing some issues with the ‘whole words’ searches.

    My configuration
    Default operator: AND (require all terms)
    Fallback to OR is enabled
    Default order is also Revelance
    Keyword matching: Partial works if no hits for whole words
    Post content: 1
    Post titles: 5
    Comment text 0.75

    I search for ‘Duration Type’ and the output is this:

    But if you scroll down you can see this: which contains both words on the title.

    I have tried to reindex but it still would produce the same result. Also the most strange thing is that in our dev environment the result would be the proper one with the exact same configuration.

    Also the post with the title is a custom post type (not sure if that’s a factor anyway).

    Any suggestion?


    • This topic was modified 1 year, 9 months ago by aglipanci.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Mikko Saari


    This doesn’t seem odd to me. The highest-ranking posts have both words, and probably have the words appear more often than the lower-ranking post, even if the lower-ranking post has both words in the title.

    Relevanssi doesn’t give any extra boost for posts that have all keywords in the title, and your title weight of 5 is fairly low. If you want titles to be really, really important, increase the title weight to 50, and I’m sure you’ll see posts with all search terms in the title rise up significantly higher.

    @msaari thank you for your quick response!
    So the primary concern that I have is to first show the posts that have the whole words ‘duration types’ and then followed by the posts which have both words but separately as it’s the result coming up on our dev site. We have some caching enabled on our site (W3 Total Cache), is that something that may impact the search results in any way? What other setting should I look at?

    Thanks for the clarification about the title weight!

    Plugin Author Mikko Saari


    Well, that proximity weighting is something Relevanssi just doesn’t do, Relevanssi gives no priority whatsoever to posts with the phrase in it.

    If you search exactly for the phrase ("duration types" with the quotes), then Relevanssi will only return posts with that exact phrase, but otherwise phrases are not accounted for (because Relevanssi only looks at the individual words).

    So that’s something you can’t easily get with Relevanssi.

    @msaari Thanks again. I really appreciate you taking the time responding to me.

    The reasons I originally thought reaching at you about this ‘issue’ was because:

    1. It’s producing the expected results in our dev site with the exact same configs
    2. I thought by setting this two settings this way would produce that result:
    Default operator: AND (require all terms)
    Keyword matching: Partial works if no hits for whole words

    • This reply was modified 1 year, 9 months ago by aglipanci.
    Plugin Author Mikko Saari


    The keyword matching setting doesn’t affect this. It means that if “duration” or “types” doesn’t find anything, Relevanssi will also look for words that begin or end with “duration” or “types”.

    I’m experiencing a similar problem, and I’ve set my “Title” weight *very* high (currently at 1000), yet a search for “South Africa” …

    … includes a result without both words,”Pursuing the China Dream through Africa: Five Elements of China’s Africa Strategy”, in 3rd place, BEFORE results *with* both words.


    Default operator: AND (require all terms)
    Fallback to OR: disabled
    Default order: Relevance
    Keyword matching: Partial works if no hits for whole words
    Post content: 2
    Post titles: 1000
    Comment text: 0

    I don’t need proximity weighting, but I really need “South Africa” stuff to come up before items with merely “Africa” in the title!

    Thanks for your help.

    Plugin Author Mikko Saari


    That post in the third place does have both words: the word “south” appears five times in the post and “africa” appears 37 times, including twice in the title. That’s why Relevanssi thinks it’s heavily about the topic.

    This Relevanssi Knowledge Base entry has some code that will increase the weight of exact title matches. That should improve your search experience.

    Thanks for your help; I’ll give this a try.

    Thanks Mikko. I added the boost function and filter (I only included the line for exact title matches, not post content), and it seems to be working great for the “South Africa” search results, but oddly, not for the “South Sudan” results:

    Any idea why this recent piece isn’t showing up in the results?

    Thanks for your help!

    Plugin Author Mikko Saari


    I’m not sure what’s the problem with the South Sudan results – they look pretty good to me, each post has “South Sudan” in the title.

    The missing post is the first post on page two, so it’s just a question of it being slightly less relevant than the posts on the page one.

    I can’t imagine how the plugin would weigh it as less relevant: I have Page Title now set to 2000, and Page Content set to 1, and still it is putting Page Content matches above an exact Page Title match. This is frustrating.

    Are these the only two factors being weighed? Is there any reason it would be further down because it is newer??

    Actually I guess the other results are all title-matches. So is it possible output all title matches in date order first, then everything else?

    I even tried weight post content at 0 then setting the order to date, but this didn’t work.

    Plugin Author Mikko Saari


    When I look at the search results, there’s nothing but title matches before it so yeah, that’s why it’s not on top.

    Relevanssi Premium includes a simple date boost option, where you can set a cutoff date (say “30 days”) and then give a weight boost to posts newer than that. That would be a simple solution for this, but that’s a Premium feature.

    Pretty much everything is possible when it comes to ordering Relevanssi results, but you’d need to write the code that sorts the results yourself.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘AND Operator not producing expected results’ is closed to new replies.