Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

postgres-semantic-search

БесплатноЗапускает вложенные скриптыНе проверен

Builds and tunes PostgreSQL retrieval with pgvector, full-text search, pg_trgm, hybrid fusion, ParadeDB BM25 and reranking. Use for pgvector columns and…

laguaguот laguagu★ 75 звёзд на GitHub

Об этом скилле

PostgreSQL Semantic Search

Decisions, measured findings and silent failure modes for search built on Postgres, plus tested SQL building blocks in scripts/. Syntax the official docs cover well is left to them; what is here goes wrong without an error.

Build order

  1. Look at what users actually type: identifiers and codes, one-to-three-word terms, full questions, which languages. That decides which arms you need.
  2. Start with the simplest retrieval suited to those queries: exact/keyword lookup or vector search. For approximate vector search, keep exact vector search as the recall baseline.
  3. Build two eval sets, long questions and short terms, before tuning (evaluation.md).
  4. Add another arm and fuse with RRF only where it improves the baseline on the queries that need it (hybrid-search.md).
  5. Add a reranker last, over the head of a good shortlist (reranking.md).

Change one thing at a time. Predefine the acceptance rule; by default require a gain beyond measured run-to-run spread on the affected query population, without a material loss on the other eval set. Inspect per-query wins/losses and require the agreed latency and cost budget to hold. The numerical findings below are corpus-specific observations, not universal performance guarantees.

Choosing

  • Column type by dimensions, not provider: vector(N) indexes up to 2,000; up to 4,000 index a halfvec cast (or use a halfvec column); above that, binary quantization or Matryoshka truncation.
  • HNSW by default, IVFFlat when memory or build time rules HNSW out. No row count decides it: measure recall and latency against exact search.
  • Models change every few months. Pick embedding and reranker models from the provider's current docs, prefer multilingual models for non-English text, and evaluate on the target language before committing.
  • Hybrid when users type both questions and terms. On a Finnish transcript corpus keyword alone was weak on long questions (24 % right first), vector alone on short terms (53 %); hybrid tied vector on long questions and led on short terms (53 % and 93 %; hybrid-search.md).
  • BM25 is not available everywhere: managed hosts differ (Neon removed pg_search). Plain FTS with the fixes below is often enough.

Silent failures

These return fewer rows, zero rows or plausible results, never an error.

pgvector (pgvector.md):

  • Without iterative scanning, HNSW results are limited by hnsw.ef_search (default 40). A larger LIMIT, or a selective WHERE, silently returns fewer. Enable hnsw.iterative_scan (off by default), or use partial indexes or partitions.
  • The default ef_search can cost recall with no warning. Raise it until recall against exact search stops moving. If EXPLAIN shows a seq scan, tuning does nothing, and the seq scan may be the faster plan.
  • A distance threshold goes outside a MATERIALIZED CTE, other filters inside it.
  • SET is per connection. Behind a transaction pooler use SET LOCAL in the same transaction, or a function-level SET.
  • Similarity cutoffs are model-specific: a cutoff tuned for one model returns nothing for another. 1 - (a <#> b) is not cosine similarity.

Keyword (keyword-search.md):

  • plainto_tsquery and unquoted plain input to websearch_to_tsquery AND bare terms, so long questions can match nothing. For plain-input retrieval, consider OR and ts_rank_cd; preserve explicit web-search quotes, OR and exclusions.
  • unaccent merges distinct words in Finnish, Swedish, German or Turkish. Fold only decorative accents, inside a text search configuration.
  • Unwanted zero-width export artifacts can glue onto tokens and block stemming. Normalize them consistently without deleting meaningful ZWNJ/ZWJ.
  • A generated tsvector column can silently become a plain NULL column after an ORM migration. If hybrid and vector-only return identical lists, the keyword arm may be absent or ineffective: check NULL/population counts and keyword-only results before diagnosing it.
  • Prefix matching in inflected languages must OR-join terms and expand hyphenated tokens (prefix_tsquery.sql).
  • % compares whole strings; use <% for prefixes and short queries against long text.

Non-English and chunking

  • Cap chunks with the selected embedding model's tokenizer and input limit. Ratios vary by model and text: with OpenAI's cl100k_base (text-embedding-3), Finnish runs about 2.5 characters per token against 4 or more for English, so an English-tuned character cap is about twice too generous. The endpoint rejects the chunk and often fails the whole batch.
  • **Off-language
Полный SKILL.md на GitHub

Установить postgres-semantic-search в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/evaluation.mdreferences/hybrid-search.mdreferences/keyword-search.mdreferences/pgvector.mdreferences/reranking.mdscripts/fuzzy_search.sqlscripts/hybrid_search_bm25.sqlscripts/hybrid_search_fts.sqlscripts/indexes.sqlscripts/prefix_tsquery.sqlscripts/semantic_search.sqlscripts/setup.sql

FAQ

Что делает скилл postgres-semantic-search?

Builds and tunes PostgreSQL retrieval with pgvector, full-text search, pg_trgm, hybrid fusion, ParadeDB BM25 and reranking. Use for pgvector columns and indexes, search/RAG implementation, weak results, filtered ANN scans, non-English corpora or retrieval evaluation. For general schema, RLS and query tuning unrelated to retrieval, use Supabase's supabase-postgres-best-practices skill.

Как установить скилл postgres-semantic-search?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл postgres-semantic-search запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить postgres-semantic-search с