Product

Feature Spotlight: Searching for facet values
facebooklinkedintwittermail

The search result a user sees usually hides a lot of underlying data.

Take this Amazon search result:

This search result already contains a lot of data, but that’s absolutely not everything that Amazon has on this blender. Where’s the department or category that this item falls into? You can filter by that on the Amazon site, so that information is definitely attached to the search result; it’s just not displayed.

Same goes for the brand: it’s part of the title in the displayed part of the search result, but we can filter by it, so it must be stored as a separate field in their search index. 

While we don’t always show every piece of data that’s technically included in the search result, we still need that data there! When we use it to power faceted search, though, we run into a new problem: what if there are more options for that facet than we can easily display in our UI? Algolia will automatically send us the first few with our first request, but in the blender example, I counted 26 different brands that Amazon’s UI has to allow me to filter by.

To tackle this problem, we released a new feature in March 2017 that lets you search for facet values. This gives you the power to explore and actually use those undisplayed values and deliver on your promise to help users cut through the noise and find what they’re looking for. 

See it in action: redoing TED search

To demonstrate this feature, we built a brand new demo based on TED talks. In this search, we have set filters based on events, the kind of conference (original, TEDx, and so on), topics and languages. Each of those filters contains more entries than we can display, which makes them perfect for using search for facet values.

Ted video search demo

Behind the scenes

Until the addition of Algolia’s search for faceted values, implementing this feature meant extra work preprocessing the data. For each faceted attribute, you had to build (and maintain) a dedicated index with the occurrences of the elements. This index had to be kept up to date, as records were added, deleted, or updated.

But not anymore! Our new functionality only requires two elements:

  • Configure the facet to be searchable: searchable(attribute) instead of attribute in the attributesForFaceting
  • Use the new method of the API to actually search in the values

This new feature added to our API is available in all our API clients using the method called searchForFacetValues(), as well as in the JS Helper. That method accepts a specific query to specify the search and the whole set of filters that you can send to index queries. This allows the search for facet values to be contextualized. This filters the values to only those that make sense for the current query.

For example, when searching for blenders on Amazon, a feature like this prevents us from getting facet suggestions like “Keurig” or “Roomba” or “Bose”. While those brands definitely do have products on Amazon, it’d be ridiculous to show those brand options when your user is searching for blenders.

Baked in our widgets

A feature isn’t useful unless it’s easy to use. Since we provide an end-to-end developer experience from the REST API to the UI, we wanted to implement the searchable refinement list right in our widget libraries instantsearch.js and react-instantsearch.

When I first looked at LinkedIn’s implementation of this facet search, something didn’t seem quite right. It felt like the feature was too hidden, like the space could be used more efficiently. We prototyped two versions of the search refinement list and we ended up with two simple implementations that we tested internally:

 

We then conducted a study with those two prototypes, and it turned out that for us the second version was the best. That was especially true for those who had no prior knowledge of the LinkedIn implementation.

This implementation is now available to you directly in instantsearch.js and in react-instantsearch. It is not a new widget, just a new option in the refinement list which will transform the list into a search one. But even that’s only scratching the surface – imagine going beyond the default implementation and integrating it right into the search box itself, like how Slack’s message box lets you refine facets while writing your message.

There’s so much more you can do with this, so if you’d like to learn more about how to get started with faceted search, check out our guides for InstantSearch and filtering/faceting.

We’re looking forward to seeing what you build with it!

About the authorAlexandre Stanislawski

Alexandre Stanislawski

Recommended Articles

Powered by Algolia AI Recommendations

Inside the Engine Part 8: Handling Advanced Search Use Cases
Engineering

Inside the Engine Part 8: Handling Advanced Search Use Cases

Julien Lemoine

Julien Lemoine

Co-founder & former CTO at Algolia
Harnessing API’s with React: a different approach
Engineering

Harnessing API’s with React: a different approach

Alexandre Stanislawski

Alexandre Stanislawski

4 questions to ask for relevant search results
Product

4 questions to ask for relevant search results

Jaden Baptista

Jaden Baptista

Technical Writer