Builds the inverted index for a document.
Writes document-level postings — one row per (term, post_id) with the
term's total frequency across all fields — to search_post_terms, and each
field's term/frequency map to search_post_fields for later diff-based
updates.
A document is written in a single UNLOGGED BATCH.
Summary
Functions
Builds the UNLOGGED BATCH statement that inserts document-level postings
plus one search_post_fields row per non-empty field.
Builds an UNLOGGED BATCH that upserts document-level posting rows only
(no search_post_fields writes). Used by the updater.
Indexes analyzed terms for every field of a post.
Functions
@spec build_batch_cql(String.t(), String.t(), %{ required(String.t()) => [{String.t(), pos_integer()}] }) :: {:ok, String.t()} | {:error, :batch_too_large}
Builds the UNLOGGED BATCH statement that inserts document-level postings
plus one search_post_fields row per non-empty field.
Values are interpolated only after validation/escaping: post_id must be a
UUID, and terms/field names become escaped CQL string literals.
@spec build_postings_batch_cql(String.t(), String.t(), [{String.t(), pos_integer()}]) :: {:ok, String.t()} | {:error, :batch_too_large}
Builds an UNLOGGED BATCH that upserts document-level posting rows only
(no search_post_fields writes). Used by the updater.
@spec index( module(), String.t(), String.t(), %{required(String.t()) => [{String.t(), pos_integer()}]} ) :: :ok | {:error, term()}
Indexes analyzed terms for every field of a post.
Takes %{"field_name" => [{term, tf}]}; aggregates the per-field maps into
document-level postings and writes everything in one batch.
Returns :ok on success or {:error, reason} on failure.