From bbfafbe519403ab16facd45f7ee5c66b851658ba Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Sat, 23 Nov 2024 12:28:06 +0000 Subject: [PATCH] Document search index schema --- lib/music_library/records/search_index.ex | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/music_library/records/search_index.ex b/lib/music_library/records/search_index.ex index 098603de..e041f9db 100644 --- a/lib/music_library/records/search_index.ex +++ b/lib/music_library/records/search_index.ex @@ -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