Smart search by keywords

I want to build a smart search with Algolia. The point is to use keywords to rank the results. Lets say user types “smarphone blue cheap good camera”. This should find all blue smarthones and order them by price and camera characteristics.

The idea is to somehow map those keywords to a ranking formula.

Doea any one know if it is possible with Algolia and if so what is the best way to achieve the desired result?

Hi @ivan.kaminskyi !

I’m going to copy/paste what I responded on StackOverflow:


To automatically detect and filter by facet values (like blue, good camera), you could use Query Rules, in particular Dynamic Filtering.

However, that shouldn’t be necessary. If you include the color (containing for instance the blue value) and characteristics (containing for instance the good camera value) attributes in your searchableAttributes list, then the search request will return relevant results based on purely textual relevance matched in those attributes.


On the other hand, sorting strategies impact the Algolia indices at build time, therefore in order to change the sorting strategy based on the query (e.g. sort results by ascending price if the search query contains cheap), you will need to setup a new replica index for which results are sorted by price. On the frontend, when detecting a relevant keyword (e.g. cheap), you can decide to switch the search queries to the primary index or to the sorted replica.