0

Let's say that we have an index with two objects:

{
"name": "iPhone 6s Plus big screen, super fast, ultra responsive, blah blah"
}

and:

{
"name" : "iPhone 6s Plus"
}

Now, when i search for iPhone 6s Plus, it returns the first object which does not make sense, since the first object contains more words (or noise) than the second object for the given query. In other words, a term appearing in a short name field should carry more ranking points than the same term appearing in a long name field

Algolia uses a TF/IDF algorithm, which takes account of the Field-length norm, so the second object should have higher score than the first one.

So why does the first object has higher score than the second one? Is there any settings option that I am missing?

flienky
  • 23
  • 1
  • 6
  • Algolia uses a tie-breaking algorithm with several different criteria. See more information here: https://www.algolia.com/doc/guides/relevance/ranking/#ranking-formula-a-tie-breaking-algorithm – Josh Dzielak Mar 29 '17 at 19:46
  • @JoshDzielak thanks for that! I posted an answer, feel free to edit it if you like, since it can help others! Thanks! – flienky Mar 31 '17 at 11:44

2 Answers2

0

I found the answer, but I am not sure if it is 100% correct, or if there is a better way to achieve this.

Login to Algolia -> Select Your Instance -> Go to Ranking Tab.

In the Ranking Formula, add a new row. The new row, should have Attribute type {{the name of the column, in this example is "title"}} and set it to Ascending.

With that, you will achieve what we are looking for.

flienky
  • 23
  • 1
  • 6
  • This will force a sorting by the full value of this field, which will work for this case but could cause other issues - doing this could override any custom ranking that you specify. – Josh Dzielak Apr 02 '17 at 20:36
0

One option is to break up the value into two different attributes, one for just the product name and another for the description. Doing that also lets you prioritize the product name in your searchable attributes, which would lead to better relevance in most cases.

Josh Dzielak
  • 1,803
  • 17
  • 19