Concepts / Going to production / Case study for an online clothing company
Sep. 17, 2019

Case Study for an Online Clothing Company

This case study is written for anyone who uses the dashboard to configure Algolia. It targets business users; no technical background is required, even though it can still be beneficial to developers as well. The primary focus of this case study is to help you get the best search results. It describes the most basic configurations to ensure consistently good results. We use a real example to make it more concrete.

Searchable Attributes

Let’s select some attributes from your index as searchable attributes. These are attributes that people use for searching.

List of searchable attributes (initial version)

  • item_name
  • description
  • price
  • image_url

Remove price and image_url. People don’t search for price, images, or URLs. These are attributes for sorting and display.

List of searchable attributes (modified version)

  • item_name
  • description

Add color and brand as searchable attributes. Even though these attributes are mostly used for filtering and faceting, people also include them in their queries, so you need to include them .

List of searchable attributes (modified version)

  • item_name
  • description
  • color
  • brand

Now focus on vertical order. Many users search for a color or a brand as well as an item’s name or description, so you should put these attributes at the top. Additionally, many users search with descriptive terms, not exact item names. Therefore, you should put description above name.

List of searchable attributes (modified version)

  • brand
  • color
  • item_name
  • description

Let’s make brand and color equal in terms of ranking. We do this by putting them on the same line.

List of searchable attributes (modified version)

  • brand, color
  • item_name
  • description

Let’s also shorten description to include only the most important search terms. You can create a new short_description attribute to accomplish this.

List of searchable attributes (modified version)

  • brand, color
  • item_name
  • short_description

Finally, let’s ensure that the contents in short_description are treated uniformly. This means that every word should have equal value; that words in the beginning, middle, and end of the description are of equal importance. You can do this with the unordered modifier. We can do the same for any multi-word attribute, like item_name.

List of searchable attributes (final version)

  • brand, color
  • unordered(item_name)
  • unordered(description)

Custom Ranking and Sorting

We start you 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.

Custom Ranking

Let’s 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 our 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

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, by adding a new replica index, which we’ll call 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

Let’s do the same for the date with a third replica, and sort from newest to oldest.

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.

Buckets - Combining Sorting 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.

Show featured items 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 ranked separately. If you have 100 results, 50 of which are featured, then the first bucket contain all featured items. These are ranked by textual relevance and custom ranking. The second bucket - the remaining 50 non-featured items - are be ranked 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, simply because it is not in the first bucket (that is, it is not a featured item).

Data Concerns

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

Duplicate objectIDs

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

Here, it looks like objects 12345 are accidentally sharing the same objectID. These records will conflict during your update logic. You need to give one of them a different objectID.

For objects ABC, this only looks like duplicate records. You should remove one of them.

Fixed, no duplicate objectIDs

  • objectID=12345 (red t-shirt)
  • objectID=67890 (Nike shoes)
  • objectID=ABC (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.

Synonyms

If you’re selling coats, you’ll notice that some people look 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 discover 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 easily become unmanageable and create false positives.

Front-End UI Concerns

Highlighting

Using highlighting let’s 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

Set 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 an eye on versions and make sure you keep them up to date. Let’s say, hypothetically, that:

  • You’re using our JavaScript client version 3.32.0. However, 3.32.1 is available (bug fix). You should update.
  • You’re using the Android client version 2.x.x. We recommend you upgrade to the next major version (3.x.x).
  • Same with your back-end server. Let’s say you’re using an outdated PHP API client (v1). You should upgrade to version v2.

Did you find this page helpful?