Today, we are thrilled to announce search for facet values, a new feature to give end-users full control to explore and actually use those hidden values, enabling you to deliver on your promise to connect your users with what matters most to them.
Facets are a key feature for a search engine, because they serve as a way to filter data by a specific value on an attribute – a good example of a facet is “brands” in an e-commerce website. With Algolia, each set of results for a search query contains the most common occurrences for each facet. This means if you have many values, some will be hidden. The simple solution to this problem is to fetch more values, but it may not be enough and the user would need to look for the value manually. Our previous solution for this problem was to recommend developers create a new index for each facet they wanted to make searchable – which was a process that created overhead.
Is faceted search still not clicking with you? Let’s dig further into the e-commerce example by assuming that you’re looking for a new pair of khaki pants from your favorite indie brand. If the brand isn’t well known, then even if you know that a store carries this brand, it may not appear in the first results or even in the list of brands among the facets if it’s not in the top ten brands of this site. You would have to filter other parameters in order for the results to be more focused on the brand you want. And that’s only if you are persistent, because we all know that Googling the website name & the name of the brand will give you some results – that’s where search for facet values comes in. It lets you filter the brands in order to find the one you want, from the very beginning of the search.
See it in action: redoing TED search
To demonstrate this new 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.
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 attributesForFacetting
- 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, in an ecommerce website for which we have two faceted attributes: type of good and color. If you search for “apples,” you don’t want purple to be proposed because there are no purple apples (not that I know of, at least).
Baked in our widgets
A feature is only as valid as its ease-of-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 instantseach.js and react-instantsearch.
When I first I looked at the LinkedIn implementation, something didn’t seem quite right. It felt as if the feature was hidden from the users and 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. It 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 but just a new option to pass to the refinement list which will transform the list into a search one.
Going further with search for facet values
Search for facet values is a great feature and with our current implementation baked into instantsearch libraries (vanilla js or react) we take advantage of it with few tweaks. But the truth is that we are only scratching the surface. This feature actually opens the door to implementation like smart search bars (like you see in Slack) that let the user refine facets within the search box.
If you’re wondering how to get started, we’ve updated our guides (because we <3 guides):
- Learn how to use this new feature in our Instantsearch result page guide
- And more in detail in the filtering and faceting guide
Let us know what cool things you’ve built in the Algolia community forum.