Exact match in a specific attribute over another

Hi there,
So I have a few attributes (title, author, content and tag) in my search formula but I want title to take precedence. In particular if the exact search query phrase is in the title, regardless of where, I want it to show first. At the moment my formula is:
with attributes

yet if I search for “the moment that” my results don’t surface the articles that have “the moment that” in the title first. I will get a recent article that has “the” in title and has “the moment that” in content. How should I fix the formula?



The searchable attributes order matters so if title is first, it will be considered more important. Please restore the default ranking formula and you should get the result you expect.

There are only very rare use cases where you need to modify the ranking formula. I’d be happy to help if you can give me more details but I in 99% of the case, the default is the best. Setting a custom ranking is important tho.

Thanks but I had the default order initially and had the same issue, which is why I tried to improve. Just tried the default order again but still doesn’t work.

The query I’m trying is “the moment that”

I first get results which have “the” in the title, and “the moment that” in content.

I want results that have “the moment that” (all the words) in title to take precedence over results that have “the” in title and “the moment that” in content. How do I do that?

Hi @paulsh,

Thanks for the follow-up. As my colleague suggested, would you be able to give the default ranking strategy another try?

I created a small test index with two records as you described:

  • Record 1: title => “the other title”, content => “the moment that”
  • Record 2: title => “the moment that”, content => “some other text”

Using our default ranking strategy, see the GIF below which on a query of "the moment that", the index returns results with the desired record first:


PS - As an aside, I noticed you put an attribute called timestamp in the middle of your ranking strategy. The standard approach would be to make that a SORT-BY attribute to hard sort the records:


1 Like

thanks Ajay. Unfortunately even when I use the exact same formula you are showing I still don’t get the same results. The formula seems to still give precedence to the latest article and shows a recent article with “the” in title and “the moment that” in content