# `Scrypath.Facets.Disjunctive`
[🔗](https://github.com/szTheory/scrypath/blob/v0.3.5/lib/scrypath/facets/disjunctive.ex#L1)

Merge helpers for Meilisearch **`facetDistribution`** JSON maps when building **disjunctive facet counts**.

A **single search** returns `facetDistribution` counts on the **same document set** as hits,
after `q` and **every active filter** (including facet refinements). Buckets therefore reflect
**conjunctive** narrowing — not "OR-group unrefined" distributions from that response alone.

**Multi-search** is how Meilisearch documents **disjunctive facet counts** (the engine’s **multi-search** batching or separate HTTP calls): run a main query,
then auxiliary queries that **drop** each disjunctive group's refinements for that group's
distribution (often `limit: 0`), then **merge** the returned maps. This module only performs
that merge on wire-level maps; it does **not** call HTTP or assemble auxiliary payloads.

# `facet_distribution_json`

```elixir
@type facet_distribution_json() :: %{
  optional(String.t()) =&gt; facet_inner_distribution()
}
```

Outer `facet_attribute => inner_distribution` map (`facetDistribution` JSON shape).

# `facet_inner_distribution`

```elixir
@type facet_inner_distribution() :: %{optional(String.t()) =&gt; non_neg_integer()}
```

Inner `value => count` map as decoded from Meilisearch JSON (counts are integers).

# `merge_distributions`

```elixir
@spec merge_distributions(facet_distribution_json(), %{
  optional(atom() | String.t()) =&gt; map()
}) ::
  facet_distribution_json()
```

Returns a deep copy of `main` where each outer key `to_string(k)` from `overrides` is
**replaced** (or **inserted** if missing) by a normalized copy of the inner map `overrides[k]`.

Parameters are **wire-level maps** (string keys on `main`), not `%Scrypath.SearchResult.Facets{}`.
Override keys may be atoms or strings; inner maps use string keys and integer counts as in JSON.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
