Arcana.Collection (Arcana v2.0.1)

Copy Markdown View Source

Represents a collection of documents for segmentation.

Collections allow you to organize documents by product, country, or any other grouping criteria. Documents can be filtered by collection when searching.

Summary

Functions

Gets an existing collection by name or creates a new one.

Extracts collection names from search/ask opts.

Resolves a list of collection names to their IDs.

Functions

get_or_create(name, repo, description \\ nil)

Gets an existing collection by name or creates a new one.

If a description is provided and the collection already exists, the description is updated only if the existing one is nil or empty.

Examples

{:ok, collection} = Collection.get_or_create("products", MyRepo)
{:ok, collection} = Collection.get_or_create("default", MyRepo)
{:ok, collection} = Collection.get_or_create("docs", MyRepo, "Official documentation")

names_from_opts(opts)

Extracts collection names from search/ask opts.

Looks for :collections (list) or :collection (single name). Returns [nil] if neither is set.

resolve_ids(names, repo)

Resolves a list of collection names to their IDs.

Returns nil for unscoped queries (when collections is [nil]), otherwise returns a list of UUIDs (possibly empty).