Updates the inverted index when a document's text changes.
Computes the diff between old and new terms:
- Fetches the old term set from
search_post_fields - Analyzes the new text to get new terms
- Removes terms present in old but not new
- Adds terms present in new but not old
This avoids re-indexing unchanged terms.
Summary
Functions
Fetches the stored term set for a post field from search_post_fields.
Updates the index for a single field of a post.
Functions
@spec fetch_old_terms(module(), String.t(), String.t(), non_neg_integer()) :: {:ok, MapSet.t()} | {:error, term()}
Fetches the stored term set for a post field from search_post_fields.
Returns an empty MapSet if no terms are found.
@spec update_field( module(), String.t(), String.t(), non_neg_integer(), [{String.t(), pos_integer()}], MapSet.t() ) :: :ok | {:error, term()}
Updates the index for a single field of a post.
Takes the repo, keyspace, post_id, field number, and the new text.
Reads the old terms from search_post_fields, computes the diff,
and applies only the necessary inserts and deletes.
Returns :ok on success or {:error, reason} on failure.