Guides / Managing results / Optimize search results

Empty or insufficient results

Displaying no results gives the impression that you don’t offer what your users want. Always displaying results gives the opposite impression: you do offer something for everybody and every situation.

For example, no results could occur when:

  • User queries are too specific.
  • Users enter multi-word queries encompassing several categories. On an ecommerce site, compare the queries tables chairs cutlery and round outdoor table: the first might reference three different categories of product, and the second might reference only one.
  • Due to poor data, users get no results for queries that should return results.

UI solutions

Here’s what you can do on the UI:

  • Show a set of related but less relevant results. Consider Query Suggestions to help display results even when there are none.
  • Show a UI-friendly “no results” page, with hints for other queries and a selection of meaningful content. You can do this with the InstantSearch or Autocomplete UI libraries.

How to avoid no results

The first step is to review your current solution.

The next step is to use advanced settings to bring back more results.

Good data

Consider:

  • The descriptive text you use in your records, especially their variety and precision. Vary your descriptions - even restating content if different phrasing and vocabulary could be equally relevant (think about the words your users might use).
  • Adding keywords to records.
  • The number of attributes. Don’t be too minimal: include all useful data. Being exhaustive will help users find what they need. You can’t predict the kinds of queries users will make, so you should cover all possibilities.
  • Using analytics to see if there are any words and phrases that you could add to your data.

Basic configuration

Algolia offers many settings that help you ensure relevant results for most queries. The following often have the most impact:

  • Synonyms. Supporting a variety of vocabulary is essential to obtain relevant results. Alternative words and spellings are common in every industry, and users have come to expect a search engine to know the lingo.
  • Typo tolerance. If you turn typo tolerance off, you’ll reduce your results. This is because Algolia will then only return exact letter-by-letter matches. If you consistently get no results, consider re-enabling typo tolerance. You can always turn off typo tolerance for specific attributes.
  • Removing stop words. By removing common words like “the”, “a”, and “it”, Algolia needs to match fewer words in a query, thereby increasing the number of results. A user may receive no results when searching for “The Invisible Man” because the film’s title is “Invisible Man”. By removing “The” from the query, users can find the movie.
  • Ignoring plurals. This means that singular and plural forms of the same word will find each other, which can significantly increase results. Without this feature, a query with a singular form (“spy”) won’t find a record with the plural (“spies”).

Using analytics

Regularly reviewing your analytics reports helps you analyze your incoming queries and think about getting better results. By looking at your top 10 queries, the most popular words and phrases, and perhaps most importantly, which searches return no results, you can make intelligent choices about your content, search, and index settings.

Advanced settings to avoid insufficient results

Algolia offers some settings explicitly designed to resolve insufficient results.

Remove words if no results

The general idea is that if the initial query doesn’t return any results, Algolia will remove one of the words from the query and redo the search. It will keep doing this until results are found or there are no more words to remove.

This technique only works with multi-word queries.

Matching individual words

This only works with multi-word queries.

By default, Algolia returns matches that contain all a query’s words:

1
"big hamster wheel" => "big" AND "hamster" AND "wheel"

Every result must contain all three words.

You can change this by allowing Algolia to return matches that contain only one of the words.

1
"big hamster wheel" => "big" OR "hamster" OR "wheel"

Now, if you have a record with “big” but not “hamster” or “wheel”, it will still be returned.

Changing this behavior will affect ranking. Records that match all three words will be ranked higher than records with only two, and records with two words are higher than records with only one. This is due to the “Words” criterion in the ranking formula.

Creating a list of optional words

You can create a list of words that, if present in a query, will be removed by Algolia. Algolia will run the query with the words and then without the words. This “double-querying” increases the number of results.

For example, say you provide online videos. If users query “action video”, you might want to make “video” an optional word. By doing this, you’re instructing Algolia to run two separate queries - “action video” and “action” - and then combine them for the ranking.

Changing this behavior will affect ranking: Records that match with all words present are ranked higher than words without the optional words. This is due to the “Words” criterion in the ranking formula.

Prefix matching is central to Algolia’s as-you-type search experience since it enables matching records based on partial words. For example, records containing apricot are immediately returned when a user types a, ap, apr. Algolia doesn’t need to wait for a full-word match before displaying results.

Hence prefix matching helps avoid insufficient results, but you can also use prefix matching to bring back even more results. By default, Algolia uses a “prefix last” logic, where only the last word in a query is treated as a prefix. All other text in the query must fully match. For example, the query “ja” will find the sentence “Jack and Jill went up the hill”. But “ja wat” won’t. That’s because only the last term, “wat”, will be used as a prefix, and the unfinished “ja” will be required to match as a complete word, which isn’t possible.

You can get more results by making all text in a query match a prefix. Now “ja wat” will find “Jack and Jill went up the hill” because “ja” matches “Jack”, and “wat” can be ignored.

However, this won’t improve relevance. Only do this when you want some randomness or have many records and care less about relevance. Image search is a good example of when near matches are desirable.

API reference queryType

Further reading

Did you find this page helpful?