Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Relationships between facets non-existant #927

Closed
danhodkinson opened this issue Jan 30, 2018 · 7 comments
Closed

Relationships between facets non-existant #927

danhodkinson opened this issue Jan 30, 2018 · 7 comments

Comments

@danhodkinson
Copy link

Bug: What is the current behavior?
Using the refinementList connector, the counts for the facet items have no relationship with each other.

Bug: What is the expected behavior?
If I select a defaultRefinementList then my other refinements don't update. No relationships exist between them.

What is the version you are using? Always use the latest one before opening a bug issue.
Latest React Instant search

Further
I have have the <SearchBox> widget, with two connectRefinementList and another connectMenu which asks as the default refinement that the user queries against.

Everything works as expected. I apply the filters on the facets and the results update. But it seems as though no relationship exists amongst them. If I add a country to my location facet. I expect the count of the hits on the other facet to be reduced.

E.g. for the defaultRefinement of a brand we have about 350 results, which is reflected in the <Stats> widget. However on the country facet, the item>count is over 1000. Which seems as though it's relationship is to the whole index. and not the existing search state.

@Haroenv
Copy link
Contributor

Haroenv commented Jan 31, 2018

Are you using distinct?

A replication of your exact setup would be nice, there's a template here

@danhodkinson
Copy link
Author

@Haroenv I'm not using distinct to my knowledge. Although it looks as though that is to do with de-duplication?

I'll attempt to get a replication set up, although i'm going through redux to maintain my store so it may take a bit of time

@danhodkinson
Copy link
Author

danhodkinson commented Jan 31, 2018

upon further inspection.. it seems that the wrapping of facets in another <InstantSearch> appears to be at the root of the issue.
using this code

<InstantSearch
            appId={config.algolia.id}
            apiKey={config.algolia.api}
            indexName={config.algolia.index}
            onSearchStateChange={this.onSearchStateChange}
            searchState={this.props.searchState}
          >
            <Facet attributeName="country" />
          </InstantSearch>

the numbers are for the full index, no matter what i query, even though the searchState is updating.
However, if I remove the wrapper then the item counts update when querying or applying other facets.. But the facets then don't persist when in a dialog box.

@Haroenv
Copy link
Contributor

Haroenv commented Jan 31, 2018

Why do you need to wrap InstantSearch instances in eachother? If you want to use several indices, you might want to try the Index component. I’m wondering what usecase you have

@danhodkinson
Copy link
Author

@Haroenv I have several facets, each in a different dialog box. The only way to have them update and persist was to have each of them wrapped around a new <InstantSearch> component (as recommended elsewhere on here. And then synced to a VirtualMenu.

@samouss
Copy link
Collaborator

samouss commented Feb 12, 2018

Hi @danhodkinson, thanks for those explanations!

It seems that your issue is linked to this one #892. If I correctly understand at the end you want that your refinements persist even when the modal is not on the screen. If you have the time to setup an example it would be great, you can find a template on CodeSandbox.

@samouss
Copy link
Collaborator

samouss commented Jun 8, 2018

I'm closing this one since it's inactive, feel free to re-open an issue.

@samouss samouss closed this as completed Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants