Rank based on string

Hi,

I have a question about ranking results based on a string instead of boolean or numeric value. I use Algolia to search trough a collection of books. In this collection of books there are books in different languages. The language is stored as a string for example: “dut” (Dutch), “eng” (English) and “ger” (German). Because our primary user is Dutch we want to give books that have language code “dut” a higher ranking but I can’t find a way to accomplish this, because the custom ranking only seems to works with boolean or numeric values. Who can help me with this? I can’t change the way it is stored because it has a direct connection with a 3th party who supplies us with the data about the books.

Something you could do, when you explicitly need a ranking that you know on beforehand, is instead of having that attribute as a string dut, you’d have an object for that attribute. One key to display and do other things with ("display": "dut") and another key for ranking, something like "ranking": 0 in this case. While indexing you have somewhere in your data how the ranking maps to a display name to keep things simple. In the end, you’d get from this:

{
  "language": "dut"
}

to this:

{
  "language": {
    ranking: 0,
    display: "dut"
  }
}

Then you can give language.ranking a high custom ranking, and display language.display.

Does that make sense?

By the way, the language code for Dutch is nl, not dut but that seems the problem of your data supplier.