django-pgsearch-patterns

Integrate Django with pg_search and pgvector for hybrid BM25 and vector search.

Updated Apr 22, 2026
One-click install
npx skills add https://github.com/Mercurium-Analytics/pg-search-vector --skill django-pgsearch-patterns
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: django-pgsearch-patterns
Source: https://github.com/Mercurium-Analytics/pg-search-vector/tree/main/skills/django-pgsearch-patterns
Command: npx skills add https://github.com/Mercurium-Analytics/pg-search-vector --skill django-pgsearch-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Django applications often need both strong full-text search and semantic similarity. This skill enables Django to leverage BM25 via pg_search and vector search via pgvector, plus a straightforward path to hybrid retrieval in Django workflows.

Core Features & Use Cases

  • BM25-based lexical search on Django models using RunSQL migrations to create BM25 indexes.
  • Vector search with pgvector using VectorField and HnswIndex for semantic matching.
  • Hybrid retrieval using pgsv.hybrid_search() from raw SQL to fuse lexical and vector results for RAG-like pipelines.
  • Django-friendly adapters like django-paradedb and pgvector.django to simplify integration and scoring.

Quick Start

Install django-paradedb and pgvector, define a model with a VectorField and HnswIndex, run migrations to create bm25 and vector indexes, and perform a hybrid search via pgsv.hybrid_search.

Frequently Asked Questions about django-pgsearch-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement hybrid search in Django combining BM25 and vector similarity?▼

Hybrid search in Django combines BM25 lexical search and vector similarity by using django-paradedb with pgvector. It fuses text and semantic results through raw SQL calls to pgsv.hybrid_search for RAG-style retrieval pipelines.

What is the best way to add full-text search to a Django model using PostgreSQL?▼

Full-text search in Django using PostgreSQL is best achieved by creating BM25 indexes via RunSQL migrations. This approach uses pg_search to enable strong lexical scoring directly on text fields within Django models.

Can I use pgvector with Django for semantic matching and RAG workflows?▼

Yes, you can use pgvector with Django for semantic matching by defining models with VectorField and HnswIndex. This enables vector similarity search to support RAG-style workflows alongside lexical search.

Do I need django-paradedb to run BM25 queries in a Django application?▼

Yes, django-paradedb is required to integrate BM25 queries into a Django application. It provides the necessary adapters to simplify indexing and scoring when using pg_search for lexical retrieval.

How does hybrid retrieval fuse lexical and vector results in PostgreSQL?▼

Hybrid retrieval fuses lexical and vector results in PostgreSQL by executing raw SQL calls to pgsv.hybrid_search. This function combines BM25 text scoring with vector similarity outputs for RAG-like pipelines.