Custom ranking works on a single value per record. The values that Algolia uses for custom ranking are:
Numbers (integers or floats)
Booleans
Strings
These values are used by the ranking formula’s tie-breaking algorithm to order records with the same textual relevance. Numeric and boolean attributes provide the most predictable and precise control over ranking, so they’re the recommended choice for custom ranking metrics.
If your data is stored as an array (for example, an array of tags or scores), you shouldn’t try to rank directly on that array. Instead, create a separate attribute that contains a single metric value derived from the array, such as:
A numeric score (for example, a popularity score, total count, or maximum value)
A boolean flag (for example,
is_featured: trueif any element of the array meets a condition)
Use this derived numeric or boolean attribute as your custom ranking attribute. This ensures that the ranking behavior is well-defined and takes full advantage of Algolia’s tie-breaking algorithm.