react-instantsearch
react-instantsearch copied to clipboard
Merge props given both in Configure and other widgets
Bug: What is the current behavior? Adding a facetFilter with Configure works. Apply a filter on a Refinement list, and it is removed.
Bug: What is the expected behavior? To merge refinements and add facetFilters from configure
Hi @zackify, could you try with the filters
attribute instead of facetFilters
?
https://www.algolia.com/doc/api-reference/api-parameters/filters/#facet-filters
Awesome thanks, that worked
We should probably merge the values though, would be less surprising?
I would think so :D
Configure should probably take precedence over the other ones.
This is causing some issues for me. I know this is an old issue, but I'm not seeing any updates for this. We were previously getting around this by using filters
on Configure instead of facetFilters
, but due to a change in requirements that's not an option anymore. Would anyone happen to have an update, or some advice for getting around this?
Which change made it impossible to use filters
? They should be functionally equal. Alternatively you can also use a custom connector using createConnector
and fill in getSearchParameters
, which will get merged with the other parameters as expected.
When using filters
, we were experiencing missing facet options from our index that we needed to see — specifically, facet options which would return 0 results, even though those our attributes for faceting are not set to filterOnly
.
I'm thinking using filters
fails to return those 0-result facet options because the filtered results the search is operating on don't contain any of those options. What we were hoping to do was to preserve all possible facet options for an index, by using facetFilters
to avoid those options getting omitted. But admittedly I'm still getting up to speed on some of these topics, so I could just be way off on all of this. 😅
Either way, is there any work going on to merge these props?
for the time being, we only received this request once four years ago, so didn't look into how it would work to merge the parameters. I think for advanced use cases like you're describing, it will be best to reference what we do ourselves in the eg. refinement list connector and edit that for your use case, rather than using configure.
Understood. Thanks @Haroenv!
I've just hit this issue too. Is there any good example of using connectWithQuery
but without needing to wrap a component?
We manage the state somewhere else, which comes in via a context/hook and then "translate" it into instantsearch language as an argument on <Configure>
like this:
<Configure
facetFilters={
buildFilterBy(filterBy, "instantsearch")
}
/>
I'm struggling to figure out how this would work with connectWithQuery
, any thoughts?
@carlreid, do you have a complete code sample somewhere? If you are managing the state manually, you could maybe look into virtual widgets or applying the refinement via a connector's refine
function. Otherwise you can always use the filters
key in configure, that is meant for "non-widget filters"
@Haroenv Nothing I could share immediately without spending some time pulling out components into a small test project.
I'll do some reading up on the virtual widgets, though had already struggled with trying to call the refine
function also. I'm having similar problems with filters
as others have described above, but again, can try tinker some more to see if I can get something working.
I understand, but to understand where you are stuck, we'll really need a code sample, sorry!