Sangeetha-Grantha

Metadata Value
Status Active
Version 1.2.0
Last Updated 2026-09-30
Author Sangeetha Grantha Team
Document Type Current guide

Catalogue search


Sangeetha Grantha has two complementary search experiences. Rasika combines hybrid discovery with the public catalogue’s predictable query/filter/paging contract. The Curator Console also offers hybrid and semantic retrieval over indexed composition overviews and lyric passages.

Choose the search mode

Mode Useful for Behavior
Lexical Known title, incipit, spelling, or phrase Text matching and conventional catalogue filters
Hybrid A phrase or topic that benefits from both exact and related matches Combines lexical and vector result ranks using reciprocal rank fusion
Semantic Meaning, related concepts, thematic discovery Retrieves from the active vector index

The admin list defaults to Hybrid, but an empty query uses ordinary browsing. Raga and composer filters apply to the console’s discovery requests. The language filter belongs to the lexical experience. A relevance score is a ranking signal, not a probability that the musicological interpretation is correct.

Rasika Explore is not a conversational assistant. On Krithis it calls POST /v1/search/hybrid and POST /v1/search/semantic as well as the catalogue. The initial mode is Hybrid, presented as the everyday search with the hint “Search titles, lyrics and meaning together.” An optional Search options disclosure offers All matches (Hybrid), Related meanings (Semantic), and Titles & lyrics (Lexical); no mode choice is required before searching. Each discovery post sends the trimmed query, null composerId and ragaId, and limit 30 (the server default of 20 is not the Rasika cap). Hybrid and Semantic are not paged. The header is “Top matches” and does not treat totalMatches as a library count. A blank query is still posted, and an empty server list is shown; Rasika does not replace it with catalogue browse. Applied raga and composer filters stay on the Lexical catalogue GET only. Their controls and chips appear only in Titles & lyrics; discovery explains that any saved filters apply only there. Ragas and Composers stay GET /v2/catalogue/ragas and GET /v2/catalogue/composers. Lexical Krithis stays GET /v2/catalogue/krithis. See the catalogue contract.

Musicological retrieval capabilities (Track 145)

With the deployment of Track 145 (Flyway migrations V66 & V67, repeatable seed R__seed_09, and Python worker Context Formatter 2.0), Sangeetha Grantha’s semantic search substrate is deeply grounded in Indian Classical Music theory (Lakshana) and sacred temple geography (Kshetra).

What makes this search discriminative

  1. Vibhakti & Enclosure Disambiguation: In cycles like the Kamalamba Navavaranam, multiple hymns address the goddess in similar high-register Sanskrit. Naive vector search collapses these hymns into an undifferentiated cluster. Context Formatter 2.0 embeds grammatical cases (aṣṭa-vibhakti), enclosure indices (Avaranas 1–9), Sri Chakra names, and Yogini clans. A query for the 6th enclosure isolates Kamalambikayastava (Punnagavarali) without colliding with the 5th enclosure (Sri Kamalambayah, Bhairavi) or 7th enclosure (Sri Kamalambikayam, Sahana).
  2. Pancha Bhuta Sthala Discrimination: Temple lingams associated with the five cosmic elements (Agni, Akasha, Vayu, Apas, Prithvi) across different regions are discriminated by elemental metadata, preventing Tiruvannamalai (Agni) from returning Chidambaram (Akasha).
  3. Patronymic Epithet Resolution: Queries citing divine relationships (such as Shani as the son of Surya) isolate Divakaratanujam without false-matching Suryamurte.
  4. Sthala Legends & Occasions: Specific miraculous events and temple rituals (e.g., the closed temple doors opening at Keevalur) directly retrieve the associated composition (Akshayalinga Vibho).
  5. Western Airs (Nottusvara Sahitya): Sanskritized colonial band tunes composed by Dikshitar during his time in Manali are retrievable by their original 18th/19th-century European air names (e.g., God Save the King, Castalian Dew).
  6. Macro Cycle & Kshetra Overviews: Generates and vectorizes synthesized overview documents for entire cycles and holy sites, including documented historical gap shrines like Kanyakumari.

Sample query phrases and expected retrieval

Category End-user query phrase Expected target composition / document Discriminative key
Sri Vidya / Vibhakti "Kamalamba sixth enclosure sarvarakshakara nigarbha yogini shashthi" Kamalambikayastava (Punnagavarali) Case: Shashthi; Chakra: Sarvarakshakara; Yogini: Nigarbha
Cosmic Elements "Dikshitar Agni lingam fire element at Tiruvannamalai" Arunachalanatham (Saranga) Bhuta: Agni; Mandalam: Nadu
Space Element "Dikshitar Akasha lingam ether element at Chidambaram" Ananda Natana Prakasam (Kedaram) Bhuta: Akasha; Mandalam: Chola
Patronymics "Dikshitar Navagraha krithi for Shani Saturn son of the Sun" Divakaratanujam (Yadukulakambhoji) Deva: Shani (“Son of the Sun”)
Sun God "Dikshitar Navagraha hymn to the Sun God Surya in Saurashtram" Suryamurte (Saurashtram) Deva: Surya
Sthala Legend "Dikshitar temple door opening at Keevalur in Shankarabharanam" Akshayalinga Vibho (Shankarabharanam) Occasion: Keevalur temple door
Western Air "Dikshitar Nottusvara composed to the tune of God Save the King" Santatam Pahi Mam (Sankarabharanam) Tune: God Save the King
Pilgrimage Gap "Muthuswami Dikshitar pilgrimage to Kanyakumari Bhagavati Amman gap temple" Kanyakumari Kshetra Overview (Macro Document) Negative Evidence; Recorded Gap
Shrine Specific "Muthuswami Dikshitar Subrahmanya kriti at Kazhugumalai shrine" Subrahmanyena Rakshitoham (Suddhadhanyasi) Kshetra: Kazhugumalai
Coastal Murugan "Dikshitar kriti praising Lord Subrahmanya at sea-shore Tiruchendur" Sri Subrahmanyo Mam Rakshatu (Todi) Kshetra: Tiruchendur

API behavior

Both POST /v1/search/hybrid and POST /v1/search/semantic accept query, optional composerId/ragaId, and limit (default 20). Results identify the composition, matched text, document kind, and available ranking scores. totalMatches is the number returned.

Index state Hybrid Semantic
No active profile Lexical-only retrieval Empty result list
Compatible active profile and indexed content Fused lexical/vector ranking Vector ranking
Active profile disagrees with query model or dimensions Availability error Availability error
Empty/whitespace query Empty API result Empty API result

Hybrid’s lexical fallback searches search_documents; it does not query the ordinary catalogue tables directly. A completely fresh index can therefore yield no hybrid results even when ordinary catalogue browsing finds compositions.

Requests without an admin role are restricted to published results. Admin identity can expose editorial results. Check both audiences when validating index visibility.

Sources: HybridSearchService, search routes, search DTOs.

Collection and kshetra cards (V2, TRACK-152)

POST /v2/catalogue/search/hybrid and POST /v2/catalogue/search/semantic take the same request body and return CatalogueSearchResponse: the unchanged kriti items, plus macroHits, a separate group of collection and kshetra cards built from the already-embedded CYCLE_OVERVIEW and KSHETRA_OVERVIEW documents. The V1 paths are unchanged: same DTO, no macro hit, and a V1 or older client never receives a hit without krithiId. The V2 routes are anonymous and published-only.

Rule Behaviour
Kriti items Identical ids and order to the V1 endpoint for a non-admin caller; the kriti SQL is not edited
Cap At most 3 macro hits per response, at most one per collection or temple (multi-chunk overviews collapse to the best chunk)
Floor Per embedding profile. For gemini-embedding-2 / 768 a card needs dense similarity of at least 0.81 and a gap of at least 0.03 over the 4th-best anchor’s similarity, or (hybrid) a lexical score of at least 0.8. A profile with no calibrated floor shows no cards (one WARN). The group is often empty; the cap is a ceiling, not a quota
Exact title exactTitleMatchId is set when the query equals a published kriti’s title or incipit (spaces ignored). Render that kriti first, then the macro group, then the other kritis
Collection eligibility The tags GET /v2/catalogue/collections returns (at least one reviewed, published member); one function in CatalogueRepository serves both
Kshetra eligibility TempleEligibility.eligibleIds(); a recorded-gap temple returns recordedGap = true
Scope filters composerId or ragaId set: macroHits is empty
No active profile Hybrid: lexical retrieval for both groups. Semantic: both groups empty
Snippet Stored overview prefix, at most 240 characters. A kshetra overview shorter than 60 characters is followed by facts already recorded for the temple (region, sacred water and tree, deity posture, published kritis and their composers); nothing is invented and the stored text and embedding are unchanged

Every COLLECTION hit opens /v2/catalogue/collections/{slug} and every KSHETRA hit /v2/catalogue/temples/{id}. The floor was chosen on the recorded scores in tools/krithi-extract-enrich-worker/evals/macro_scores.json (2026-11-02): the labelled macro hits score 0.836 to 0.852 with a gap of 0.044 to 0.050, the exact-title kriti probes peak at 0.787, and cards that look wrong score 0.819 to 0.823 with a gap of 0.004 to 0.013. MacroFloorsMarginTest holds those margins. After changing the embedding profile or the overview text, re-record the scores with evaluate_retrieval.py --dump-macro-scores evals/macro_scores.json, recalibrate, and re-check with evaluate_retrieval.py --via-api <base-url>; the command also reports V1/V2 items parity.

Sources: RasikaSearchService, MacroSearchRepository, CatalogueSearchDtos.

Curator preview of mobile search (TRACK-158)

The Curator Console’s Mobile Preview runs this same V2 pipeline through admin-gated routes: POST /v1/admin/preview/search/{hybrid|semantic} wraps the unchanged V2 response with an explanation (active profile, the floor, every macro candidate and why it was hidden) and, for scope: INCLUDE_UNPUBLISHED, the ids of unpublished results. GET /v1/admin/preview/krithis/{id}/index-status reports whether the search index may be behind an edit, from timestamps. These routes are read-only, rate-limited to 20 requests per minute per curator and not recorded in the mobile usage log.

Ranking and result identity

Semantic retrieval uses cosine similarity (1 - cosine distance) and selects one representative matched document per composition. Hybrid retrieves up to 500 lexical and vector candidates per branch, combines document ranks with 1/(60 + vectorRank) + 1/(60 + lexicalRank) for the available branches, then selects one representative per composition. Small overview preferences influence representative selection.

The repository clamps requested limits to 1–100. Composer filters use the composition identity; raga filters match the primary raga or membership in krithi_ragas. Anonymous/non-admin scope requires both a published composition and visible search document. similarityScore, lexicalScore, and rrfScore are different measures; a displayed percentage is not a calibrated confidence probability.

Source: KrithiSearchRepository.

Index architecture

flowchart LR
    C[Canonical compositions and lyric sections] --> F[Context formatter]
    F --> D[search_documents]
    F --> G[Document embedding client]
    G --> E[document_embeddings]
    P[embedding_profiles] --> E
    Q[Query] --> K[Query embedding client]
    K --> R[Vector retrieval]
    E --> R
    Q --> L[Lexical retrieval]
    R --> H[Rank fusion]
    L --> H
    H --> A[Admin result cards]

Migration V58, Migration V66, and Migration V67 define the storage contract: profiles identify model/dimensions/task type, documents identify composition/section/variant or macro cycle/kshetra anchors, and embeddings bind a document to a profile. Vectors are stored as vector(768) with a cosine HNSW index. The current tooling defaults to gemini-embedding-2 with MRL truncation to 768 dimensions; model availability and billing are external operational concerns.

Indexing is a separate operation from importing. Importing a composition does not establish that its latest text has been embedded. The tools compare content hashes, retire obsolete documents, audit writes, and support profile activation after a successful run.

The embedding guide describes document eligibility, metadata context, direct versus locally batched execution, content hashes, profile activation, and read-only coverage queries. See TRACK-145 Implementation Summary for the musicological enrichment architecture.

Populate or refresh the index

Run from the worker directory after configuring the intended database and embedding credentials. Inspect the plan first:

cd tools/krithi-extract-enrich-worker
uv sync --frozen --extra dev
uv run python scripts/embed_catalogue.py --limit 5 --dry-run

For an authorized indexing run:

uv run python scripts/embed_catalogue.py --limit 5

For concurrent full-catalogue batch embedding:

uv run python scripts/batch_embed_catalogue.py --concurrency 8 --delay 0.05 --report-path /tmp/embedding-run.md

To refresh the macro cycle and kshetra overviews (never --include-macro, which also walks every krithi), check, preview, then embed only what is stale:

uv run python scripts/embed_catalogue.py --macro-only --check
uv run python scripts/embed_catalogue.py --macro-only --dry-run
uv run python scripts/embed_catalogue.py --macro-only

The macro embeddings runbook covers the order, the success output and the read-only SQL form of the check.

Use the script’s --help for --krithi-id, --all, --force, --model, and --activate-profile. Keep the backend query embedder and active profile aligned. A different model needs its own profile and compatible index coverage before activation. Dimension changes require a storage migration; changing a flag cannot resize the existing column.

The batch indexing script shares index-maintenance logic with the direct runner. See TRACK-108 implementation and TRACK-145 implementation for rollout evidence.

Diagnose results

  1. Verify the composition exists and its workflow state permits the requesting audience to see it.
  2. Verify search_documents, document_embeddings, and the active profile for the intended database across all 4 document kinds (COMPOSITION_OVERVIEW, SECTION_PASSAGE, CYCLE_OVERVIEW, KSHETRA_OVERVIEW).
  3. Compare the indexed text/hash with current lyrics, especially after reingestion or section repairs.
  4. If the API reports unavailability, inspect embedding credentials, provider failures, and profile compatibility.
  5. Compare a known-title lexical query with the hybrid/semantic result. A thematic miss alone is not evidence of a parser failure.
  6. Verify retrieval precision using evaluate_retrieval.py against the 31 retrieval benchmark probes.

Operations covers logs and runtime configuration; quality checks cover deterministic tests and retrieval evidence.


Section index · Documentation home · Feature status