Turn off typo tolerance when searching by SKU
Algolia supports searching by SKU and other numbers by default, if you include them as searchable attributes. By default, typo tolerance is turned on for numbers as well. That’s helpful when you don’t want to limit the search results to exactly matching numbers, for example, when searching for product variants or physical sizes. When searching by SKU however, it’s better to turn off typo tolerance to allow for more precise searching. If you add your SKU attribute todisableTypoToleranceOnAttributes
, the search results only include products with exactly matching SKU.
Search in hyphenated attributes
By default, Algolia regards hyphens as separators, so searching for “123-X-456” and “123 X 456” returns the same results. If you also want to allow searching for the number without spaces, for example, “123X456”, it’s important to consider all variations.Detect searching intent with Rules
You can guide buyers effectively by using Rules to detect keywords in a search query. To learn more, see:Let users search by custom aliases for products
B2B buyers often return to buy the same products. Typing or copying SKUs or other lengthy product identifiers every time can be tedious and error-prone. Some ecommerce platforms allow buyers to save a custom alias, or reference, for an item. With Algolia, you can use Rules to support searching by a custom alias to speed up the search. For example, the buyer can save an aliasmy_product
for the product with the ID “123-456-789”.
You can create a rule that detects the alias and replaces it with the product ID.
When the buyer searches for my_product
, Algolia applies the rule and returns the product matching the SKU.
JavaScript
ruleContexts
when searching.
For example, using an API client:
Guide users by increasing search precision
For example, if a buyer searches for “article ref21”, they might look for an item that starts with the number “21”. If that’s the case, you can create a Rule to increase the precision of the search, by:- Removing the keyword “article”
- Restricting the searchable attributes to the title and ID
Define a rule using the API clients
Define a rule using the Algolia dashboard
- Go to the Rules page in the Algolia dashboard.
- Click the New rule button.
- Select Create your first rule or New rule and select Manual Editor.
-
In the Condition(s) section, keep Query toggled on, select Contains,
and enter
article
in the input. -
In the Consequence(s) section:
- Click the Add consequence button and select Add Query Parameter.
- In the input field that appears, enter the JSON search parameter you want to add.
For example,
{ "restrictSearchableAttributes": ["title","id"] }
. - Click the Add consequence button again and select Remove Word.
- Enter
article
in the input field.
- Save your changes.