Skip to content

Commit f836516

Browse files
Merge #918
918: Fix keepZeroFacets on disjunctive facet search r=bidoubiwa a=bidoubiwa Since introducing the multi-index search here #888 the setting `keepZeroFacets` was broken. This PR introduces the fix to this issue https://user-images.githubusercontent.com/33010418/207385436-e49ded20-e76b-4974-86de-904cfeecfbd7.mp4 What was done in this pr: - keepZeroFacet management has been moved to the response adapter instead of the request adapter - Filtering methods and filtering tests were removed as the new facet distribution management has completely changed - `defaultFacetDistribution` is renamed `initialFacetDistribution` and contains the distribution of an index without any other requests - Initialization of facet distribution was moved from client to its own file Playgrounds: - New SingleMovieIndex playground to create a new environment for testing - Updated `SingleIndex` with keepZeroFacets - Updated `MultiIndex` with keepZeroFacets Co-authored-by: Charlotte Vermandel <[email protected]>
2 parents 7951ab5 + 40a13a7 commit f836516

17 files changed

+867
-356
lines changed

src/adapter/search-request-adapter/__tests__/facets-distribution-assigns.tests.ts

Lines changed: 0 additions & 96 deletions
This file was deleted.

src/adapter/search-request-adapter/__tests__/filter-cache.tests.ts

Lines changed: 0 additions & 71 deletions
This file was deleted.

src/adapter/search-request-adapter/__tests__/search-params.tests.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { adaptSearchParams } from '../search-params-adapter'
2-
import { MatchingStrategies } from '../../../types'
2+
import { MatchingStrategies, SearchContext } from '../../../types'
33

4-
const DEFAULT_CONTEXT = {
4+
const DEFAULT_CONTEXT: SearchContext = {
55
indexUid: 'test',
66
pagination: { page: 0, hitsPerPage: 6, finite: false },
7-
defaultFacetDistribution: {},
87
placeholderSearch: true,
98
keepZeroFacets: false,
109
}

src/adapter/search-request-adapter/filters.ts

Lines changed: 0 additions & 128 deletions
This file was deleted.

src/adapter/search-request-adapter/search-resolver.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
SearchCacheInterface,
66
MeiliSearchParams,
77
} from '../../types'
8-
import { addMissingFacets, extractFacets } from './filters'
98

109
/**
1110
* @param {ResponseCacher} cache
@@ -42,16 +41,6 @@ export function SearchResolver(
4241
.index(searchContext.indexUid)
4342
.search(searchContext.query, searchParams)
4443

45-
if (searchContext.keepZeroFacets) {
46-
const cachedFacets = extractFacets(searchContext, searchParams)
47-
48-
// Add missing facets back into facetDistribution
49-
searchResponse.facetDistribution = addMissingFacets(
50-
cachedFacets,
51-
searchResponse.facetDistribution
52-
)
53-
}
54-
5544
// Cache response
5645
cache.setEntry<MeiliSearchResponse>(key, searchResponse)
5746

0 commit comments

Comments
 (0)