AshScylla.Search.Indexer.Builder (AshScylla v1.6.1)

Copy Markdown View Source

Builds the inverted index for a document.

Takes the analyzed terms and writes them to the search_post_terms table and the raw terms set to search_post_fields for later diff-based updates.

Uses UNLOGGED BATCH for efficient bulk writes.

Usage

Indexer.Builder.index(repo, keyspace, post_id, field_num, [
  {"phoenix", 2},
  {"elixir", 1}
])

Summary

Functions

Indexes the analyzed terms for a single field of a post.

Indexes analyzed terms across multiple fields for a post.

Functions

index(repo, keyspace, post_id, field, terms)

@spec index(
  module(),
  String.t(),
  String.t(),
  non_neg_integer(),
  [{String.t(), pos_integer()}]
) :: :ok | {:error, term()}

Indexes the analyzed terms for a single field of a post.

Writes term → post_id mappings to search_post_terms and stores the set of unique terms in search_post_fields for future diffing.

Returns :ok on success or {:error, reason} on failure.

index_fields(repo, keyspace, post_id, fields_map)

@spec index_fields(
  module(),
  String.t(),
  String.t(),
  %{required(non_neg_integer()) => [{String.t(), pos_integer()}]}
) :: :ok | {:error, term()}

Indexes analyzed terms across multiple fields for a post.

Accepts a map of %{field_num => [{term, tf}]} and writes all rows.