Case Study for an Online Clothing Company
On this page
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 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 using a real example to make it more concrete.
Selecting searchable attributes
When configuring relevance, you should start by selecting some attributes from your index as searchable attributes. These are attributes that people use for searching.
Initial list of searchable attributes
- 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.
Modified list of searchable attributes
- item_name
- description
Add color
and brand
as searchable attributes. Even though these attributes are often used for filtering and faceting, people also include them in their queries, so you need to include them .
Modified list of searchable attributes
- 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
.
Modified list of searchable attributes
- brand
- color
- item_name
- description
You should make brand
and color
equal in terms of ranking. You can this by putting them on the same line.
Modified list of searchable attributes
- brand, color
- item_name
- description
You should shorten description
to include only the most important search terms. You can create a new short_description
attribute to do this.
Modified list of searchable attributes
- brand, color
- item_name
- short_description
Finally, ensure that the contents in short_description
are treated uniformly. This means that words in the beginning, middle, and end of the description are of equal importance. 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
- brand, color
- unordered(item_name)
- unordered(description)
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
Setting sorts
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, called products_sorted_by_price_descending
for example.
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)
- 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 e-commerce use cases. This type of sort provides the most relevant results instead of strictly 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, on the query “red skirt”, items like “red shirt” wouldn’t be included in the sort because they’re less relevant. This would remove noise for the users.
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’s not in the first bucket—that is, it’s not a featured item.
Using unique objectID
s to preserve your data
Some of your records may have duplicate objectID
s. This will cause 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 objects 12345
accidentally share the same objectID
. If you try to index them both, the index retains only one. You should make sure that each items 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 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 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.
- Implement 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:
- You’re using the 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. You should upgrade to the next major version (3.x.x).
- Same with your back-end server. Say you’re using an outdated PHP API client (v1). You should upgrade to version v2.