Implement dynamic facets
See original GitHub issueDo you want to request a feature or report a bug? This is a feature request – both for instantsearch.js and react-instantsearch. It might make sense to have something implemented in the Helper that would then be leveraged in instantsearch.js.
Feature: What is your use case for such a feature?
This is a need mainly stemming from e-commerce use cases, but could be useful for any use case that involves a wide variety of facets.
In large e-commerce selling many different types of products (from electronic devices to groceries), displaying the facets that make sense for any given search is a problem.
Besides the generic price
, brand
or categories
facets, there’s no way to know in advance what will make sense to display in the facets.
If a user searches for tv
you’ll want to display facets for connectivity, size of screen, screen technology, etc. — for a query like printer
you’d display things like number of pages per minutes, included scanner, connectivity, and so on.
The way we solve this today is by doing the following:
- Each record has two attributes:
relevant_properties
andproperties
. They’d look something like this:-
{ "properties": { "Connectivity": ["HDMI", "WiFi"], "Screen Size": "50" }, "relevant_properties": ["Connectivity", "Screen Size"] }
-
relevant_properties
andproperties
are added to the attributes for faceting- at each keystroke, a first search query is sent with the query string (+ possible active facets),
facets=['relevant_properties']
andhitsPerPage=0
. This retrieves the properties that are the most represented in the query results. - Once the results come back for that first query, a second query is sent to actually fetch the hits, along with the facets that have been returned/extracted from the results of the first query.
I have built a fiddle to demonstrate this using the JS helper: https://jsfiddle.net/rbbosLh3/ Unfortunately the only dataset I had handy for this usecase is a french one, sorry.
Feature: What is your proposed API entry? The new option to add? What is the behavior? Today there’s no (easy) way to dynamically remove/add widgets in an instant search implementation, which makes it hard to implement this solution.
I’m not sure what should be the API/modifications made to our libs to make this work, but it would be nice to have something friendlier than going back down to the helper for this.
What project are you opening an issue for?
- react-instantsearch
- instantsearch.js
- algoliasearch-helper?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:16 (13 by maintainers)
Top GitHub Comments
Updated above link with a public guide: https://github.com/algolia/dynamic-faceting-instant-search-guide/blob/master/guide.md
@olance & @bobylito let me know if you think this guide is useful: https://github.com/algolia/dynamic-faceting-instant-search-guide/blob/master/guide.md