Guides / Going to production

Case Study for an Online Clothing Company

This case study is helpful to configure Algolia using the dashboard. The process targets business users with no technical background and is just as useful to developers. The main goal is to help you follow the right steps and consistently get great search results.

The real-world case study gives a better picture of the configuration process.

Selecting searchable attributes

Attributes are the key-value pairs that compose records and the records compose an index.

You need to select the most relevant attributes a user can search for. For example, on an ecommerce search, searchable attributes could be name or description.

Initial list of searchable attributes

  • name
  • description
  • price
  • image_url

From the initial list, you wouldn’t select price or image_url. These attributes are useful for sorting and display, a user wouldn’t search for those.

Selecting your searchable attributes

  • name
  • description

Add color and brand as searchable attributes. These attributes are often used for filtering and faceting, but people also use them in search queries.

Adding more attributes

  • name
  • description
  • color
  • brand

Now to further improve relevance, you need to move the most relevant attributes to the top of the list. In this case, users tend to search for a color or a brand as well as an item’s name or description. It then makes more sense to have these attributes higher in the list.

Users tend to search with descriptive terms instead of exact item names. To account for it, put description first on the list, before name.

Listing the most relevant attributes first

  • description
  • name
  • brand
  • color

You could find that brand and color are just as relevant to your users. You would then put them both on the same line, separated by a comma.

Listing two equal ranking attributes

  • description
  • name
  • brand, color

Long attributes like description can be too noisy and generate false positives in relevance. Such attributes are often primary terms that make up multiple search terms. In such cases, you can create a derived, shorter attribute and pick just the search-relevant terms. For example, for the attribute description, create a short_description attribute with just the useful search terms from description.

Replace a noisy attribute with a more efficient one

  • short_description
  • name
  • brand, color

You might want to ensure that all the words in short_description have the same importance. This means that words in the beginning, middle, and end of the description are uniformly relevant. You can do this with the unordered modifier. You can do the same for any multi-word attribute, like item_name.

Final list of searchable attributes

  • unordered(short_description)
  • unordered(name)
  • brand, color

Setting custom ranking and sorting

You start off with Algolia’s out-of-the-box ranking formula.

Default ranking

  • Default ranking formula

You shouldn’t change or remove this ranking formula. It works out of the box for 99% of use cases.

Setting custom ranking

You can now customize your ranking by adding some business metrics. It’s typical to add popularity attributes, such as number of likes or best sellers. It’s also worth leveraging Click and Conversion Analytics to rank according to the products with the most successful conversion rate.

Custom ranking (main index)

  • Default ranking formula
  • number_of_sells
  • popularity
  • conversion_rate

Sorting by a specific attribute

You might want to allow your users to sort by a specific attribute. To do so, you can leverage Algolia’s sorting capability, which requires you to create a replica index for each sort.

For example, you can sort by price, from highest-priced items to lowest. To do this, you can create a new replica index called products_sorted_by_price_descending.

Sort by price, highest to lowest (replica 1)

  • price (sort-by, descending)
  • Default ranking formula

To reverse the order and sort by ascending price, you need to add another replica index, products_sorted_by_price_ascending.

Sort by price, lowest to highest (replica 2)

  • price (sort-by, ascending)
  • Default ranking formula

Do the same for the date with a third replica, and sort from newest to oldest.

Sort by date, newest to oldest (replica 3) –> ### Sort by date, newest to oldest (replica 3)

  • date (sort-by, descending)
  • Default ranking formula

You should now have four indices: a main index + three replicas:

  • your main index with custom ranking (by best-sellers, popularity, and conversion rate),
  • your three replicas, which are:
    • sorted by price, descending,
    • sorted by price, ascending,
    • sorted by date, descending.

If your plan includes it, Relevant sorting offers the best user experience for most ecommerce use cases. This sort provides the most relevant results instead of sorting on attributes like price and date. Relevant sorting also doesn’t require data duplication, keeping your application leaner.

For example, for a price ascending sort, the query “red skirt” wouldn’t return items containing “red shirt” because they’re less relevant. Relevant sorting removes noise for users.

Creating buckets to combine sorts with custom ranking

You might want to add a field like featured, a true or false value that forces all featured items to show up first.

  • featured (sort-by, descending)
  • Default ranking formula
  • number_of_sells
  • popularity
  • conversion_rate

By doing this, you’re creating two buckets of results, where each bucket is individually ranked. If you have 100 results, 50 of which are featured, then the first bucket contain all featured items. The featured items rank by textual relevance and custom ranking. The second bucket—the 50 non-featured items—rank by textual relevance and custom ranking.

One consequence with buckets is that you may have the most textually relevant record appear in the 51st position because it’s not in the first bucket—that is, it’s not a featured item.

Using unique objectIDs to preserve your data

Some of your records may have duplicate objectIDs. This causes problems when updating your data.

Duplicate objectIDs

  • objectID=12345 (red t-shirt)
  • objectID=12345 (Nike shoes)
  • objectID=67890 (Levi jeans, slim)
  • objectID=67890 (Levi jeans, slimmed)

Here, it looks like two objects share the same objectID of 12345. If you try to index them both, the index retains just one. You should make sure that each item has its own unique objectID.

The items with objectID:67890 look like duplicate records. You should remove one of them.

Fixed, no duplicate objectIDs

  • objectID=12345 (red t-shirt)
  • objectID=23456 (Nike shoes)
  • objectID=67890 (Levi jeans, slim)

Language settings

If you haven’t set up your language to that of your users, you should do so. Also, make sure that you’ve set ignorePlurals and removeStopWords to true.

Defining synonyms

If you’re selling coats, you may notice that some people search for “coats” and others for “jackets”. In your store, these are the same.

Your synonyms

  • coat=jacket

You may also want to add a synonym for shoes and boots, so that users who are looking for shoes can find boots as well. To do this, create a synonym for “shoes” and “boots.”

Your synonyms

  • coat=jacket
  • shoes=boots

Keep this list up to date with as many synonyms as necessary, but not too many. A long list of synonyms can become unmanageable and create false positives.

Front-end UI concerns

Highlighting

Using highlighting lets your users instantly see why a record is present in the results.

Without highlighting

Query: nike

Results

  • Nike Air is the best
  • Magic Nike is built to last

With highlighting

Query: nike

Results

  • Nike Air is the best
  • Magic Nike is built to last

Instant search results and as-you-type search experience

Implement instant search results. This comes out of the box with the InstantSearch libraries with a default for as-you-type search.

Setting up facets

Do you have useful categories in your index, like colors or brands? Add them as facets and display them on your UI to let your users filter their results.

Staying up to date

You should keep your clients and libraries up to date. For example:

  • Ensure that you update both your front-end library and search client to the latest version, including patches.
  • Ensure that you update your indexing client and any other relevant libraries to the latest version.

Did you find this page helpful?