Applies aggregate-level index diffs for a document.
Postings are stored at document level (one row per term with total
frequency), while search_post_fields keeps per-field maps. An update:
- Computes the new merged document totals from the stored field maps and the newly analyzed fields
- Deletes posting rows whose total dropped to zero
- Upserts posting rows whose total changed
- Rewrites the
search_post_fieldsrows of every updated field
This keeps multi-field documents correct even when a term is shared across fields (removing it from one field only lowers the total).
Summary
Functions
Applies a precomputed diff between merged old and new document totals.
Functions
@spec apply_diff( module(), String.t(), String.t(), [{String.t(), pos_integer()}], [String.t()], %{ required(String.t()) => [{String.t(), pos_integer()}] } ) :: :ok | {:error, term()}
Applies a precomputed diff between merged old and new document totals.
upserts—[{"term", new_total}]postings that are new or changeddeletes—["term"]postings removed entirelyfield_maps—%{"field" => [{term, tf}]}analyzed maps of the fields being updated; fields with an empty list have their stored row deleted
Returns :ok on success or {:error, reason} on failure.