Ignoring numbers in search query

Hi there,

I would like our search to be a bit more loose on number values for search queries.

If there is an exact match, I’d like that to rank higher on the results. If there isn’t an exact match for those numbers, I’d like for it to still show results without accounting for the number values.

Here is an example:

What is the vapor pressure of ethanol at 19 ∘C?

That returns zero results right now, even though we have this as a record:

What is the vapor pressure of ethanol at 15°C?

I’ve tried tweaking a lot of the “relevance optimizations” settings, but I can’t figure out how to change a setting to achieve what I’m trying to do.

Any help would be appreciated.


Hello Alain,

Thanks for your question!

The problem in this case is that “15°C” is considered as a one word since there is no space separator between the numeric value and °C. If the query was written this way: "What is the vapor pressure of ethanol at 19°C?"the default settings would return the correct article because there would be only one character difference in a 4 char word, and it would be considered as a typo. Because there is an additional space in the query, the engine doesn’t recognise it as the same word.

One solution that would work for this specific query (and very precise queries like this one) is to set the fallback behaviour in case of no result to ignore the last words of the query with removeWordsIfNoResults set to lastWords : https://www.algolia.com/doc/api-reference/api-parameters/removeWordsIfNoResults/.

If the tricky words were to be found in the middle of the query, you could set it to allOptional.

Another more generic solution would be to use synonym placeholders in your record if you have a set of predefined possible values: https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/in-depth/synonyms-placeholders/.

I hope this helps!

Let us know if you have any other question.


Thanks Marie.

I will experiment with setting removeWordsIfNoResults set to lastWords. The allOptional option is just too broad to be useful for us.