For a keyword-based search such as Algolia, searching for dimensions or measurements (such as “6x12 mm” or “3' x 1") presents several challenges:
-
Algolia's default normalization process at query-time removes all non‑alphanumeric characters (such as quotes, apostrophes, and unit symbols).
-
Tokenization logic may further hinder accurate matching.
-
Typo tolerance offers some flexibility but won't consistently resolve dimension-related mismatches.
If dimensions are important to your search use case, we recommend using a transformation function to transform this dimension data in your records as outlined in this guide.
A transformation function will allow you to extract dimensions and generate standardized dimension keywords (in multiple formats and units) to include in a dedicated attribute for reliable matching. For example, a dimension that appears as 30 × 50 in in your pre-transformation data can generate variants including:
-
30in x 50in -
30 x 50 -
30in50in 30" x 50"
By transforming and indexing all relevant variants in a dedicated searchable attribute (i.e. dimension_keywords), you can deliver reliable high-relevance results for your end-users across a variety of query formats.
***
Alternatively, you can "force" / "funnel" the appropriate dimension format and terms via your front-end UX. If your records are indexed with well-defined and well-formatted measurement data, you can use a specific section on the front-end to gear your end-users towards typing that information in a specific area (like a "measurements" text field) that will align with the dimension format in your records. Though not as comprehensive as the transformation approach, this method still allows for more accurate search based on the information typed in those user-defined fields.
***
Lastly, if the approaches above are not possible for your use case, you might consider adding single and double-quote characters (often used to infer inches, feet, etc.) to the separatorsToIndex configuration. This will prevent the characters from being removed by normalization, although you may still face relevancy limitations due to tokenization.