Hide irrelevant filters when they barely return products - #1355
Open
indykoning wants to merge 2 commits into
Open
Hide irrelevant filters when they barely return products#1355indykoning wants to merge 2 commits into
indykoning wants to merge 2 commits into
Conversation
indykoning
commented
Aug 13, 2026
Comment on lines
+134
to
+141
| ({ instantSearchInstance }) => { | ||
| this.instantSearchInstance = instantSearchInstance | ||
| return { | ||
| onStateChange: () => {}, | ||
| subscribe: () => {}, | ||
| unsubscribe: () => {}, | ||
| } | ||
| }, |
Member
Author
There was a problem hiding this comment.
Adding a middleware to the instantsearch initialization gives us easy access to the instantsearchInstance.
Hacks we've used in the past were
export default {
inject: {
instantSearchInstance: {
from: '$_ais_instantSearchInstance',
},
},
...Alternatively custom widgets could be used: https://www.algolia.com/doc/guides/building-search-ui/widgets/create-your-own-widgets/vue
That would mean every filter would need another Vue component wrapping it.
This current method gives us access to the instantSearchInstance within any Listing component.
Member
|
Looking good to me, let's wait for a review from @Jade-GG + successful Playwright tests |
royduin
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR attempts to hide irrelevant filters from listings.
As some examples:
A Category page with many different types of products could have a filter dedicated to a small subset of those products:
a filter with 4 options, one returning 19 products, one 13, one 2 and one 1.
We're on a category page with 622 products. This means on a page where we have 622 products we show a filter that would only ever be able to display a maximum of 35 products.
That's not a very relevant filter, however when we start filtering. Getting to 100 products that filter is relevant again. Calculating it to a percentage would be:
((19 + 13 + 2 + 1) / 622 * 100)= 5.6%Filtering it a little to 176 products:
((19 + 13 + 2 + 1) / 176 * 100)= 19.8%By calculating a percentage between total possible products in filter, and all current products we ensure only relevant filters that filter enough products are shown. But pages with only few products don't get impacted.