How it works
Meilisearch does not have a built-in disjunctive facet mode. Instead, you implement it client-side using multi-search. The idea is to send multiple queries in a single request:- One main query with all active filters applied, returning the hits and facet counts for non-disjunctive groups
- One query per disjunctive facet group where you remove the filters for that group, so its counts reflect the broader result set
color = Red and brand = Nike:
| Query | Filters applied | Facets requested | Purpose |
|---|---|---|---|
| Main | color = Red AND brand = Nike | ["size"] | Get hits and non-disjunctive facet counts |
| Color query | brand = Nike | ["color"] | Get color counts without the color filter |
| Brand query | color = Red | ["brand"] | Get brand counts without the brand filter |
Implementation
Step 1: track active filters by group
Organize your active filters by facet group so you can selectively exclude each group:Step 2: build the multi-search request
For each facet group that has active selections, create an additional query that excludes that group’s filters:limit: 0 on the per-group queries avoids fetching duplicate hits. You only need the facetDistribution from these queries.
Step 3: send the multi-search request
Step 4: merge facet distributions
Combine the facet distributions from all queries into a single object for your UI:Full example
Putting it all together with a complete search function:Performance considerations
Disjunctive facets require one additional query per facet group with active selections. In practice this is fast because:- Multi-search executes all queries in a single HTTP request
- Per-group queries set
limit: 0, so Meilisearch skips ranking and document retrieval - Meilisearch processes multi-search queries concurrently
Next steps
Multi-search
Learn more about multi-search and how to batch queries.
Build faceted navigation
Standard faceted navigation pattern for simpler use cases.
Optimize facet performance
Reduce indexing time and search latency for faceted search.