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★ 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
- Look at what users actually type: identifiers and codes, one-to-three-word terms, full questions, which languages. That decides which arms you need.
- 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.
- Build two eval sets, long questions and short terms, before tuning (evaluation.md).
- Add another arm and fuse with RRF only where it improves the baseline on the queries that need it (hybrid-search.md).
- 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 ahalfveccast (or use ahalfveccolumn); 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 largerLIMIT, or a selectiveWHERE, silently returns fewer. Enablehnsw.iterative_scan(off by default), or use partial indexes or partitions. - The default
ef_searchcan cost recall with no warning. Raise it until recall against exact search stops moving. IfEXPLAINshows a seq scan, tuning does nothing, and the seq scan may be the faster plan. - A distance threshold goes outside a
MATERIALIZEDCTE, other filters inside it. SETis per connection. Behind a transaction pooler useSET LOCALin the same transaction, or a function-levelSET.- 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_tsqueryand unquoted plain input towebsearch_to_tsqueryAND bare terms, so long questions can match nothing. For plain-input retrieval, consider OR andts_rank_cd; preserve explicit web-search quotes, OR and exclusions.unaccentmerges 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
Установить postgres-semantic-search в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
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 запускает скрипты?
Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.
Похожие скиллы
agent-skill-stack
Find, evaluate, and assemble the smallest compatible set of AI Agent Skills for an end-to-end natural-language goal. Use when a user wants Skills for a…
от GitHubbuild-evidence-map
Build an auditable evidence map for a contested technical choice, research synthesis, proposal review, or consequential decision. Use when Copilot must…
от GitHubpinecone-rag
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions…
от GitHubqdrant-monitoring-debugging
Diagnoses Qdrant production issues using metrics and observability tools. Use when someone reports 'optimizer stuck', 'indexing too slow', 'memory too high'…
от GitHub