Default search refinement list

Hello,

I want to apply a default value to some refinementLists. I’ve added them into the searchParameters with disjunctiveFacetsRefinements and disjunctiveFacets. But then only 1 value is shown.

It’s a bit hard to explain what I mean but I hope this helps:

http://markputs.nl/algolia.php When you visit this page and go to the Merken filter you now only see 1 brand, Michelin.
http://markputs.nl/algolia2.php When you visit this page and go to the Merken filter you will see all available brands in that size. When you click Michelin you still see those other brands.

How can I set default filters for the brands and still see the other available brands?

Thanks!

Hi Mark, http://markputs.nl/algolia.php actually sets brand to Michelin and also model to crossclimate. Which results in only michelin being available for this model.

Checkout http://markputs.nl/algolia2.php, click on michelin then crossclimate (search for it) and you’ll see the same result.

Hope it helps.

Weird, I really thought my examples were like I said… :stuck_out_tongue:

Anyways, let me ask the question in a different way:

The most important filter at our website is our tire size filter - this one is applied by default with the facet name ‘maat’. This should be the base for all filters.

We would like to show all filter options that are available with the current maat facet. So for example when you visit http://markputs.nl/algolia.php we would like to not only show the brand (Merk) Michelin, but we would also like to show all brands that are available in the current size. Like http://markputs.nl/algolia2.php has - but then with a 0 in the count area.

Is this possible?

Hi @mark, the Algolia API has no way to send you facet values where counts is 0 unfortunately.

What you could do is inline those brands in your UI with the 0 count (so put them in your HTML/JS no matter what the Algolia API sends).

A tricky question then is: as a user, can I click on one of those 0 facets? And if so, what happens on the UI/search?

Hi,
I want apply also a default value to a specific widget “refinementList”.
search.addWidget(
instantsearch.widgets.refinementList({
container: ‘#date-refinement’,
attributeName: ‘is_passed?’,
showMore: true,
templates: {
header: ‘Type’
}
})
);
When my page is loaded I want set a default option to display only futur event but if the user want i can display post avent also.
This is possible ?
THanks

Hi @lamarque.matthieu you should be able to do so by using:

instantsearch({searchParameters: {filters: 'is_passed:value'});

Let me know how it goes.

Thanks,

I already tried that but unfortunately I would like to have choice between true or false option.
With you answer I can’t select other option.

05

Hi @lamarque.matthieu, could you create a CodeSandbox example with what you tried to achieve until now.

Can you explain us in business needs what you want to achieve? Something like “I have objects with this shape: … I would like to allow the user to be able to select… based on … with default values…”

Thanks!

Hi
Yes this my code :


I have objects with a boolean attribute (past or not)
When my instantSearch is loading I would like to have a refinementList with auto selected (true or false) to display only futur object.
Moreover if the user want search inside past objects he can.

If I add filters: ‘is_passed?:true’ the is_passed is autoselected but the user can’t retrieve other state.

Thanks for your help

I just made a change that should be what you want: https://codesandbox.io/s/woj1ll26xk

Let me know how it goes.

Exactly, Thanks Vincent !