Document search index schema

This commit is contained in:
Claudio Ortolina
2024-11-23 12:28:06 +00:00
parent 2e2000fe01
commit bbfafbe519
+10 -3
View File
@@ -1,12 +1,19 @@
defmodule MusicLibrary.Records.SearchIndex do
@moduledoc """
The search index is backed by a virtual table that uses
the [FTS5](https://www.sqlite.org/fts5.html) extension.
Data in the table is automatically synced via a set of triggers defined in
`priv/repo/migrations/20241122094655_create_records_search_index.exs`.
Most of the `records` table columns are replicated for ease of use -
so that it's not necessary to fetch actual `records` after obtaining search results.
"""
use Ecto.Schema
@formats [:cd, :vinyl, :blu_ray, :dvd, :multi]
@types [:album, :ep, :live, :compilation, :single, :other]
# q = from s in MusicLibrary.Records.SearchIndex,
# where: fragment("records_index = 'lex*'"), select: s.id
@primary_key {:id, :binary_id, autogenerate: false}
schema "records_search_index" do
field :type, Ecto.Enum, values: @types