Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve selected facets first with disjunctiveFacets #24

Open
afunnydev opened this issue May 5, 2020 · 3 comments
Open

Retrieve selected facets first with disjunctiveFacets #24

afunnydev opened this issue May 5, 2020 · 3 comments

Comments

@afunnydev
Copy link

afunnydev commented May 5, 2020

Let's say we are using the facet with the following options:

const options = {
  facets: {
    location: [{ type: 'value', size: 6 }],
  },
  disjunctiveFacets: ['location'],
  filters: { location: ['Canada', 'United States']},
};
client
  .search('yoga', options);
  .then(({ info }) => {
    console.log(info.facets.location);
  });

If the location Canada is not in the first 6 most popular facet results for this query, it is not included in info.facets.location. Only the 6 most populars are accessible. However, I can see we retrieve this data from the request that is not Facet-Only (since it returns only the two facets that we used to filter).

If we use the facets results to display checkboxes (with multiple selection active), it is a problem since the Canada option will not be shown, and then cannot be remove from the filters. We need to "cache" that selected value, and then display it without it's count.

I don't know if this should be implemented at a endpoint level, but I think the active filters should be returned as the first values when retrieving facet values, so that the UI can be implemented out-of-the-box. Even if they are empty (count = 0). That way, it will be easier to implement a UI based on them.

@JasonStoltz
Copy link
Member

I agree, this is a good feature suggestion. And yes, I think it should definitely be at the endpoint level. In the meantime, I would recommend fetching a much larger "size" and implement that sort yourself.

@afunnydev
Copy link
Author

Thanks. That's what I'll do for the moment. It's unfortunately still a issue for selected facets with no results, since they are not returned even if the size is large. I will just cache that for now. Curious on how bad the impact on performance couldl be for a size > 100 (meaning I query for litteraly all facet values)?

@JasonStoltz
Copy link
Member

I wouldn't expect it to be bad. Try experimenting with it, I'd be curious to know how it performs as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants