If a query doesn’t return any results, Algolia can progressively remove words to broaden the search.
This process is called query expansion.
For example, consider an online shop that sells iPhones with 128 GB and 256 GB storage.
Users searching for iPhone 256gb would see no results.
Showing relevant results is better than showing none.
Query expansion strategies
To support query expansion,
Algolia offers the removeWordsIfNoResults parameter.
It defines how Algolia modifies queries with no results by removing words based on one of four strategies:
none (default), lastWords, firstWords, allOptional.
Use search analytics to identify typical patterns:
- Which terms usually appear first in queries.
- Which terms correlate with clicks or conversions.
- Which ones most often lead to “no results”.
How to apply a query expansion strategy
You can configure the removeWordsIfNoResults parameter in one of the API clients.
- Go to the Algolia dashboard and select your Algolia .
- On the left sidebar, select Search.
- Select your Algolia index and open the Configuration tab.
- Select Search behavior > No results behavior.
- Select your strategy.
Test your query expansion strategy
To check whether the strategy works for your users’ typical search patterns,
apply the strategy and test queries in the dashboard.
To validate your strategy, consider running an A/B test with:
- Control (A): set
removeWordsIfNoResults to none.
- Variant (B): set
removeWordsIfNoResults to use your chosen strategy.
A successful test should show:
Non-alphanumeric characters
When you change removeWordsIfNoResults from its default none,
this can affect how Algolia applies special processing to queries with non-alphanumeric characters:
- Algolia can treat hyphens and other characters as separators. For example, the query
t-shirt may match tshirt and t shirt. For more information, see Splitting and concatenation
- Algolia enforces the order of words in a query. For example,
t-shirt matches t-shirt but not shirt t. For more information, see Tokenization.
These behaviors affect how word removal works.
For example, if a user searches for XYZ-b5,
you might expect the query to eventually match only XYZ.
But because of concatenation and tokenization,
it matches XYZ b5 or XYZb5, not only XYZ.
See also
Last modified on August 27, 2026