Search by Algolia
Algolia's search propels 1,000s of retailers to Black Friday success
e-commerce

Algolia's search propels 1,000s of retailers to Black Friday success

In the midst of the Black Friday shopping frenzy, Algolia soared to new heights, setting new records and delivering an ...

Bernadette Nixon

Chief Executive Officer and Board Member at Algolia

Generative AI’s impact on the ecommerce industry
ai

Generative AI’s impact on the ecommerce industry

When was your last online shopping trip, and how did it go? For consumers, it’s becoming arguably tougher to ...

Vincent Caruana

Senior Digital Marketing Manager, SEO

What’s the average ecommerce conversion rate and how does yours compare?
e-commerce

What’s the average ecommerce conversion rate and how does yours compare?

Have you put your blood, sweat, and tears into perfecting your online store, only to see your conversion rates stuck ...

Vincent Caruana

Senior Digital Marketing Manager, SEO

What are AI chatbots, how do they work, and how have they impacted ecommerce?
ai

What are AI chatbots, how do they work, and how have they impacted ecommerce?

“Hello, how can I help you today?”  This has to be the most tired, but nevertheless tried-and-true ...

Catherine Dee

Search and Discovery writer

Algolia named a leader in IDC MarketScape
algolia

Algolia named a leader in IDC MarketScape

We are proud to announce that Algolia was named a leader in the IDC Marketscape in the Worldwide General-Purpose ...

John Stewart

VP Corporate Marketing

Mastering the channel shift: How leading distributors provide excellent online buying experiences
e-commerce

Mastering the channel shift: How leading distributors provide excellent online buying experiences

Twice a year, B2B Online brings together America’s leading manufacturers and distributors to uncover learnings and industry trends. This ...

Jack Moberger

Director, Sales Enablement & B2B Practice Leader

Large language models (LLMs) vs generative AI: what’s the difference?
ai

Large language models (LLMs) vs generative AI: what’s the difference?

Generative AI and large language models (LLMs). These two cutting-edge AI technologies sound like totally different, incomparable things. One ...

Catherine Dee

Search and Discovery writer

What is generative AI and how does it work?
ai

What is generative AI and how does it work?

ChatGPT, Bing, Bard, YouChat, DALL-E, Jasper…chances are good you’re leveraging some version of generative artificial intelligence on ...

Catherine Dee

Search and Discovery writer

Feature Spotlight: Query Suggestions
product

Feature Spotlight: Query Suggestions

Your users are spoiled. They’re used to Google’s refined and convenient search interface, so they have high expectations ...

Jaden Baptista

Technical Writer

What does it take to build and train a large language model? An introduction
ai

What does it take to build and train a large language model? An introduction

Imagine if, as your final exam for a computer science class, you had to create a real-world large language ...

Vincent Caruana

Sr. SEO Web Digital Marketing Manager

The pros and cons of AI language models
ai

The pros and cons of AI language models

What do you think of the OpenAI ChatGPT app and AI language models? There’s lots going on: GPT-3 ...

Catherine Dee

Search and Discovery writer

How AI is transforming merchandising from reactive to proactive
e-commerce

How AI is transforming merchandising from reactive to proactive

In the fast-paced and dynamic realm of digital merchandising, being reactive to customer trends has been the norm. In ...

Lorna Rivera

Staff User Researcher

Top examples of some of the best large language models out there
ai

Top examples of some of the best large language models out there

You’re at a dinner party when the conversation takes a computer-science-y turn. Have you tried ChatGPT? What ...

Vincent Caruana

Sr. SEO Web Digital Marketing Manager

What are large language models?
ai

What are large language models?

It’s the era of Big Data, and super-sized language models are the latest stars. When it comes to ...

Catherine Dee

Search and Discovery writer

Mobile search done right: Common pitfalls and best practices
ux

Mobile search done right: Common pitfalls and best practices

Did you know that 86% of the global population uses a smartphone? The 7 billion devices connected to the Internet ...

Alexandre Collin

Staff SME Business & Optimization - UI/UX

Cloud Native meetup: Observability & Sustainability
engineering

Cloud Native meetup: Observability & Sustainability

The Cloud Native Foundation is known for being the organization behind Kubernetes and many other Cloud Native tools. To foster ...

Tim Carry

Algolia DocSearch is now free for all docs sites
product

Algolia DocSearch is now free for all docs sites

TL;DR Revamp your technical documentation search experience with DocSearch! Previously only available to open-source projects, we're excited ...

Shane Afsar

Senior Engineering Manager

4 questions to ask for relevant search results
product

4 questions to ask for relevant search results

Relevance – it’s what we’re all going for with our search implementations, but it’s so subjective that it ...

Jaden Baptista

Technical Writer

Looking for something?

facebookfacebooklinkedinlinkedintwittertwittermailmail

What is faceted search? A critical Search UI feature, where users can click on facet values to filter their search results. 

This is the second article in a three-part series of blog posts that describe the technical and data aspects of facets and faceted search. Here in part 2, we examine a variety of data structures applied to different facet use cases.

Like many front-end UX patterns, faceted search requires a precise and well-tailored facets JSON dataset. Luckily, there are many ways to represent facets in a JSON record. Most faceting is simple, only needing only a single-word filter to describe a product or service — an apple is a fruit, Apple is a brand. We can use a single attribute to represent “apple”:

{
    "name": "apple",
    "type": "fruit",
    "seasonal_categories": ["fruits->late-summer", "fruits->autumn"]
}

or

{
    "name": "iPhone 8 Gold Protection Screen",
    "brand": "Apple",
    "category": ["smartphone->protective-screens"]
}

The facets “type” and “brand” are single-dimension attributes. But facets can get more complicated: you can set them up as hierarchies or nested attributes. In this article, we’ll see how different facet data models achieve different front-end functionalities, all of which are central to faceted search and guided navigation:

Building a facets data model into JSON records

We’ll go into four common ways to define facets and filters. Each one has its purposes and advantages:

  • Simple (“type”: “fruit”)
  • Nested (actors->( (actor1->name, actor1->character_name), (actor2 …) ) )
  • Hierarchies (“category: food->fruit->seasons”)
  • Tagging (tags: “drama”, “fun to watch with friends”, “must watch again”)

Simple facets

The simplest facets are the most important to start with. They convey the essence of an object with a minimum of keywords. A shirt is either short-sleeved or long-sleeved. A movie has only one average rating. But simple facets can also have multiple values. A t-shirt can have one color or be a mix of red and blue. A movie can be a “romantic sci-fi comedy spoof”. Simple and exact tagging help bring back the best items to your users, giving them exactly what they were looking for. In our previous article on faceted search, we spoke about how facets are not only for filtering but also for searching.

Using JSON, simple facets are easy to represent:

{
    "name": "bold t-shirt",
    "desc": “Be bold, wear a t-shirt with only one color”,
    "color": “white”,
    "sleeves": "short"
},
{
    "name": "Hippie Vest with Fringes",
    "desc": “Be hip: get back to where you belong, peace + love”,
    "color": ["red", “orange”, “yellow”, “green”, "blue"],
    "sleeves": "long"
}

Nesting facets

More advanced facets contain nested information. Nesting is all about structuring your data. Data structuring tells a story about an item. Let’s compare a single non-nesting example to different kinds of nesting.

Simple values:

{
   "name": "Brad Pitt"
}

Simple nesting:

{
   "first_name": "Brad",
   "last_name": "Pitt"
}

Nesting with a bit more complexity:

{
    "actors": [
     {
        "first_name": "Brad",
        "last_name": "Pitt"
     },
     {
        "first_name": "Scarlett",
        "last_name": "Johanson"
     }
   ]
}

* In this article, we use actors for searching and as facets to filter results by specific actors.

When to use nested facets for faceted search

You don’t always need to structure, or nest, your data. With search, your main concern is finding the record, which is all about content, not structure. Finding “brad pitt” will work just as good with a simple or complex structure.

While structuring JSON may add human clarity to a given record, the engine can work with simple or complex structures. Structuring data always requires more thinking and more time to maintain, so it’s important to consider its value and purpose before overthinking it.

However, simple nesting enables you to anticipate search patterns. For example, if people rely on last names to find authors, it makes sense to create a “last_name” attribute.

{
    "last_name": "King",
    "first_name": "Stephen"
},
{
    "last_name": "Shakespeare",
    "first_name": "William"
}

More complex nesting can be used for display purposes, not just for filtering or search. One example is displaying itemized information about your items. Let’s compare two use cases, one that needs simple attributes, the other more complex nesting. A company selling DVDs does not necessarily need to overthink structure. They just need to make sure the record contains enough necessary information for its users to find a movie. Here’s a likely structure with only two attributes:

{
    "title": "Avengers: Infinity War",
    "cast": ["Robert Downey Jr", "Chris Hemsworth", "Mark Ruffalo", "Chris Evans", "Scarlett Johansson"]
}

On the other hand, a website that provides detailed information about a film, like IMDB or Netflix, needs to display more structured information:

{
  "title": "Iron Man",
  "cast": [
    {
      "first_name": "John",
      "last_name": "Smith",
      "birth_year": "1978",
      "birth_place": "New York City, New York"
    },
    {
      "first_name": "Robert",
      "last_name": "Downey Jr",
      "birth_year": "1965",
      "birth_place": "New York City, New York"
    }
  ]
}

This latter record contains data for an onscreen information box. The only caveat is that when your index contains complex nesting, you need to indicate to the engine which part of the structure to search. For example, you’ll need to designate “cast.first_name” and “cast.last_name” as searchable, and “cast.birth_year” as both searchable and filterable.

Hierarchies

Many faceted search experiences offer users the ability to browse category and subcategory hierarchies, helping them to narrow or broaden their search. You can use hierarchies to create category-based menu systems. While designing and maintaining complex categories takes time, hierarchies create a great faceted search and navigational experience when done right. Take a look at how a supermarket can categorize its data to help people find the right online aisle:

[
{
    "name": "lemon",
    "categories.lvl0": "products",
    "categories.lvl1": "products > fruits"
},
{
    "name": "tomato",
    "categories.level0": "products",
    "categories.level1": "products > summer",
    "categories.level2": "products > summer -> vegetables"
}
]

Booksellers also do it, with each author organized into different categories, some with multiple hierarchies:

{
    "name": "Ursula K. Le Guin",
    "categories": [
        "level0": "Books",
        "level1": ["Books > Science Fiction", "Books > Literature & Fiction"],
        "level2": ["Books > Science Fiction > Time Travel", "Books > Literature & Fiction > Literary"]
    ]
}

Tagging – User-created or AI-generated

Not all facets need to be managed by you and your company. Users have their own ideas about how to define and categorize your products and services. For example, you might classify “Breaking Bad” as a TV series and a Crime Drama. But users will have other ideas. Here, we group all user tags under the attribute “_tags”:

{
    "title": "Breaking Bad",
    "_tags": ["drugs", “father figure”, “cancer”, “midlife crisis”, “violent”, “not for kids” ]
}

And it’s not only users who add facet tags. Increasingly, machine learning algorithms and other forms of AI combine user behavior, product descriptions, market data, and more, to find helpful ways to tag items. For example, as users search, click, and view your catalog, AI auto-tagging can improve the categorization of your products by adding surprising alternatives. You can get age group, purpose, and other characteristics of products that you hadn’t thought about.

A popular example of this is image auto-tagging, where image detection algorithms generate a set of common tags for images. Websites like Pinterest that offer gifs and images make use of this kind of technology.

Imagine that users are consistently buying certain items before every major holiday. AI-generated tags might generate the following.

{
    "name": "Scotch tape",
    "_tags": ["Christmas", “Halloween”, “New Years”]
}

This information can be used to merchandise and manage your content, such as making sure that “Scotch tape” shows up high in the search results during holiday seasons.

Additionally, you can transform tags as facets into your records. Here, we’ve analysed the tag and created a new facet “holiday_accessory”:

{
    "name": "Scotch tape",
    "holiday_accessory": true
}

Leveraging your multi-purposed facets data model

As described in our previous article of this series on faceted search, facets are useful for searching content. Having facets that match keywords entered in by users improves your search measurably. On a functional level, the engine doesn’t actually care that it is searching a category, a simple facet, or a non-facet. It looks where it is told to look. It’s therefore important to direct your engine to look at the specific attribute needed.

With this in mind, we discussed how complex nesting structure returns results that tell a story about an item in a record. Amazon returns results not only with product name, description, price, and an image. Its results also include ratings, shipping info, popularity, and categories.

The secret here is to put all that extra information into one searchable index. You can repurpose every attribute, using them for search, filtering, and/or display purposes. This avoids a second trip to another part of your database to retrieve additional information.

We’ll be speaking more about that in the next article of this series on faceted search.

Parting words on the facets data model

Simple and complex facets create a faceted search and navigational experience based on browsing — with or without search. You can display facets in many ways — on the left-side of the screen, front and center, as drop downs, menus, and many other creative ways to make it easy for users to browse with single clicks.

But wherever they appear on the screen, and however you design them in your data, facets enable your users to click and browse and ultimately discover your full online catalog of products and services. Here, the technical point is that the underlying JSON structure must be well-tailored to support your front-end’s needs. This article hopes to have presented a solid foundation for common use cases in any sector or domain.


 

This is the second article in our Facets & Data series. Our focus in this series is technical, outlining the logic and facets data model of facet search.

  • The first article — Facets and faceted search, every JSON attribute counts — is where we define what faceting is, and explain the critical role that facets play in structuring your data. It also illustrated how JSON is the most flexible way to represent your index data including facets.
  • In this article — the second article — we introduce the most common data structures for facets: simple facet values, nested faceting, hierarchical categories, and user and AI tagging, all of which are used for different aspects of facet search.
  • The third article — Implementing faceted search with dynamic faceting — data continues to be our central focus, but we also discuss process. We look at the query search process, from query to execution to response, and show how to generate facets dynamically.
About the author
Peter Villani

Sr. Tech & Business Writer

linkedinmediumtwitter

Recommended Articles

Powered byAlgolia Algolia Recommend

Implementing faceted search with dynamic faceting (code included)
engineering

Peter Villani

Sr. Tech & Business Writer

Faceted Search: An Overview
ux

Jon Silvers

Director, Digital Marketing

How to create a great faceted search and navigation experience
ux

Louise Vollaire

Product Marketing Manager