Match count based ranking

Is it possible to have algolia rank search results based on how many times a query word is matched in a searchable attribute for a record? I didn’t see an out-of-the-box solution for a case like this in the docs, but please let me know if I missed it.

In the following example, the index contains two entries for different cars. Each car has user-defined descriptors. Searching for “fast” should return both results with the Tesla returned first (because Tesla has two descriptors that match the query “fast”, while Maserati has only one) while searching for “expensive” should yield the Maserati followed by the Tesla. The ordering of the descriptors does not matter, so searching for “fast and expensive” or “expensive and fast” could produce a tie when ranking the two records, but “expensive and cool” would return the Maserati first because more descriptors match the query.

    "car": "Maserati Quattroporte",
    "descriptors": ["expensive", "fast", "expensive", "cool"]
    "car": "Tesla Roadster",
    "descriptors": ["fast", "fast", "cool", "expensive"]

Note that the descriptors are user-defined text and could be anything. Each car could have hundreds of descriptors. The idea is that the more users label the Maserati as “expensive”, the higher it will rank when searching for “expensive”.

Algolia actually very explicitly doesn’t assess term frequency when ranking results as we’ve found it’s not a very good way of predicting relevance. Instead we ranking based on things like term proximity and number of matching attributes. This is an old, but still relevant article that explains our methodology:

1 Like