Only returning correct number


I have a lot of products where the width is searchable.

Width examples:

All ends with 2", so when I search for 2" all sizes are visible. Is there a way to filter all others out when dealing with numbers e.g.? I’m not sure what kind of logic I need to make this happen correctly :slight_smile:

Hi Peter,

Maybe it will be more convenient to facet your results on width? So that the user can focus on other search terms and then filter the results with the chosen width. You can also consider a range filter:

What do you think?

Hi Nicolas.

Thanks for responding. The problem is of now, that the width is just part of a headline textstring, and not a seperate key in the data object. My clients want to be able just to type in 2" and then get all the 2" results. Isn’t that possible at all?

Hi @peter2,

Maybe you can share with us the website you’re talking about along with some queries and the expected results you wanted to see? It will help us try to understand the best strategy for your use case.


Hi Marie

Sure thing.

You can see it here:"

The first result has 2.562" in the headline. It after that the 2" comes. But down the line 1/2" is also present. It would be nice to have filtered all others beside 2" out.

The ranking config to get this work would really alter the search experience. You would need to disable typo-tolerance, tweak the proximity distance and have an exact match with prefix set up.

What I suggest is to go for the width attribute, but hidden under the hood. As the width still appears in the title, it will be transparent for the user, but relevance will improve. Then you could set width as a facet, and configure a query rule to filter results with this facet:

Okay… and maybe when I create an under the hood width, at the same time create a headerWithoutWidth or something like that. So I can search the header without the width. Then I will have to have an exact match on the width field. That oughta be possible right? Im not happy about disabling typo tolerance though… one of the things i sold Algolia to the client with :slight_smile:

Yes, the suggested solution did not involve disabling typo tolerance, so keep it globally, along with the query rule on the facet :). Maybe try first with a single width facet, and you can disable typo tolerance only for this attribute.