Do 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:
relevant_properties and properties. They'd look something like this:js
{
"properties": {
"Connectivity": ["HDMI", "WiFi"],
"Screen Size": "50"
},
"relevant_properties": ["Connectivity", "Screen Size"]
}
relevant_properties and properties are added to the attributes for facetingfacets=['relevant_properties'] and hitsPerPage=0. This retrieves the properties that are the most represented in the query results.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?
This actually sounds more like an API feature than a library feature to me, but does sound very useful.
@Haroenv yup indeed, but it's not clear yet that this would be implemented at the API level
I talked about this with @bobylito last week, and he suggested to search with facets:*, and then only render those that are deemed relevant X times. Although doing two requests isn’t a terrible idea, this alternative is having one bigger request (granted that you don’t have thousands of facets)
Could the relevant facet be used in the display of the hits too?
@Haroenv @bobylito searching with facets:* is what this method is working around. This is terrible in terms of performance, as the total number of facet attributes are usually in the hundreds or thousands in that kind of scenario.
@bobylito I did not get your question
@olance Your method retrieves the most relevant facets right? And facets are attributes of the records, so could we use those to makes custom hits rendering?
Ah, I think I do get it now 😛
Do you mean using the dynamic facets to display the relevant information at the hits level as well?
Yes 😅
@bobylito Sorry, holidays :)
So yeah now I have understood what you meant 🙌
It totally makes sense, however I'm not sure how you'd tie that with the requested feature?
Make the dynamic facet values available within the widget template?
@olance I had the opportunity to work on an actual implementation with @sepehrfakour. This uses the searchFunction, which can't be made into a widget. I'm thinking a guide for that.
@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
Link results in 404 here?
The link is private right now. @sepehrfakour, should it be made public and iterated when needed?
Let's ensure we provide a public link soon or remove this private link (with explanations on why) for now (can raise frustration from users). cc @sepehrfakour
Updated above link with a public guide:
https://github.com/algolia/dynamic-faceting-instant-search-guide/blob/master/guide.md
done in #4687, more information in the doc to come
Most helpful comment
Updated above link with a public guide:
https://github.com/algolia/dynamic-faceting-instant-search-guide/blob/master/guide.md