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

fix(facets): choose highest value in disjunctive #6536

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Haroenv
Copy link
Contributor

@Haroenv Haroenv commented Jan 20, 2025

Summary:

When doing disjunctive faceting, there are two different sets of results:

  1. the results with the filter applied
  2. the results without the filter applied

Normally we want to use the facets of result 2, as those don't have the other constraints applied. think for example of this:

[
  {
    "facetFilters": ["f:alpha"],
    "hits": [{ "f": ["alpha", "beta"] }],
    "facets": { "f": { "alpha": 1, "beta": 1 } }
  },
  {
    "hits": [{ "f": ["alpha", "beta"] }, { "f": ["beta", "gamma"] }],
    "facets": { "f": { "alpha": 1, "beta": 2, "gamma": 1 } }
  }
]

This was the behaviour before #6445. In #6445 we have swapped the order, to cater for "more tricky" use cases like non-exhaustive second response, less results in second response due to remove words optional or distinct.

see #6482, CR-7169, #6445.

Result:

Therefore now we take the middle ground: use the highest value. This works for all existing test cases, as well as newly introduced ones that simulate the "array" use case.

When doing disjunctive faceting, there are two different sets of results:

1. the results with the filter applied
2. the results without the filter applied

Normally we want to use the facets of result 2, as those don't have the other constraints applied. think for example of this:

```json
[
  {
    "facetFilters": ["f:alpha"],
    "hits": [{ "f": ["alpha", "beta"] }],
    "facets": { "f": { "alpha": 1, "beta": 1 } }
  },
  {
    "hits": [{ "f": ["alpha", "beta"] }, { "f": ["beta", "gamma"] }],
    "facets": { "f": { "alpha": 1, "beta": 2, "gamma": 1 } }
  }
]
```

This was the behaviour before #6445. In #6445 we have swapped the order, to cater for "more tricky" use cases like non-exhaustive second response, less results in second response due to remove words optional or distinct.

Therefore now we take the middle ground: use the highest value. This works for all existing test cases, as well as newly introduced ones that simulate the "array" use case.

see #6482, [CR-7169], #6445.
@Haroenv Haroenv requested review from dhayab, a team and sarahdayan and removed request for a team January 20, 2025 11:41
Copy link

codesandbox-ci bot commented Jan 20, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e015085:

Sandbox Source
example-instantsearch-getting-started Configuration
example-react-instantsearch-getting-started Configuration
example-react-instantsearch-next-app-dir-example Configuration
example-react-instantsearch-next-routing-example Configuration
example-vue-instantsearch-getting-started Configuration

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

Successfully merging this pull request may close these issues.

1 participant