iPhone 256gb
would see no results.
Showing relevant results is better than showing none.
Query expansion strategies
To support query expansion, Algolia offers theremoveWordsIfNoResults
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β.
Strategy | Best when⦠| Expansion example | Trade-offs |
---|---|---|---|
none (default) | You only want exact matches. | iPhone 256gb . Queries are never expanded. | Can lead to βno resultsβ pages. |
lastWords | Users type the most important terms first. | iphone 5 32gb β iphone 5 β iphone | May lose nuance if key information is at the end of the query. |
firstWords | Users type the most important terms last. | sparkly blue iPhone cases β blue iPhone cases β iPhone cases β cases | May lose nuance if key information is at the beginning of the query. |
allOptional | Full recall, when returning something is better than nothing (useful for blogs and broad product catalogs). | blue iPhone cases . Matches any word: blue towels, iPhone repair kits, camera cases. | Maximizes recall but sacrifices relevance. |
allOptional
works like the optionalWords
parameter,
which is sent at query time.
For more information,
see Creating a list of optional words.How to apply a query expansion strategy
You can configure theremoveWordsIfNoResults
parameter in your API client.
- Go to the Algolia dashboard and select your Algolia application.
- 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
tonone
. - Variant (B): set
removeWordsIfNoResults
to use your chosen strategy.
- Fewer βno resultsβ in search analytics.
- No significant drop in click and conversion rates.
Non-alphanumeric characters
When you changeremoveWordsIfNoResults
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 matchtshirt
andt shirt
. For more information, see Splitting and concatenation - Algolia enforces the order of words in a query. For example,
t-shirt
matchest-shirt
but notshirt t
. For more information, see Tokenization.
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
.