Algolia Custom Ranking on the Fly

Viewed 767

I have an index of thousands of music tracks. For searching I want the tracks to be returned by track title ascending.

I also have the created_at field which is a date time of when I added the track to library. Is it ok for me to change the ranking on the fly?

So for my normal artist / title search before the query I would run:

index.setSettings({
  ranking: [
    "asc(title)",
    "asc(artist)"
  ]
});

And then when I want to return the tracks I recently added to the database I would run:

index.setSettings({
  ranking: [
    "desc(created_at)",
    "asc(title)",
    "asc(artist)"
  ]
});

My question is: Is this performant? Are there any down sides for doing this for each query?

Thanks for the advice!

1 Answers
Related