Skip to main content

Vector search for Django models with graph relations

Project description

Django Graph Search

Production-ready vector search for Django models with automatic relation traversal.

  • Search across related models (FK, M2M, reverse relations)
  • Pluggable vector stores (ChromaDB, FAISS, Qdrant)
  • Delta indexing with configurable cache
  • Admin UI and REST API out of the box

Fast Start (5 minutes)

1) Install

pip install django-graph-search[chromadb]

Other backends:

pip install django-graph-search[faiss]
pip install django-graph-search[qdrant]
pip install django-graph-search[all]

2) Add app

INSTALLED_APPS = [
    ...,
    "django_graph_search",
]

3) Configure

GRAPH_SEARCH = {
    "MODELS": [
        {
            "model": "shop.Product",
            "fields": ["name", "description", "category__name", "tags__name"],
            "follow_relations": True,
            "relation_depth": 2,
        },
    ],
    "VECTOR_STORE": {
        "BACKEND": "django_graph_search.backends.ChromaDBBackend",
        "OPTIONS": {
            "persist_directory": "vector_db",
            "collection_name": "django_search",
        },
    },
    "EMBEDDINGS": {
        "default": {
            "BACKEND": "django_graph_search.embeddings.SentenceTransformerBackend",
            "MODEL_NAME": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
            "OPTIONS": {},
        },
        "fast": {
            "BACKEND": "django_graph_search.embeddings.SentenceTransformerBackend",
            "MODEL_NAME": "sentence-transformers/all-MiniLM-L6-v2",
            "OPTIONS": {},
        },
    },
    "DEFAULT_EMBEDDING": "default",
    "DEFAULT_RESULTS_LIMIT": 20,
    "DELTA_INDEXING": True,
    "CACHE": {
        "BACKEND": "file",  # file | redis | db
        "OPTIONS": {"path": "graph_search_cache"},
        "KEY_PREFIX": "dgs",
        "TTL": 86400,
    },
}

4) Add URLs

urlpatterns = [
    ...,
    path("api/search/", include("django_graph_search.urls")),
]

5) Build index

python manage.py build_search_index

6) Search

GET /api/search/?q=wireless+headphones&models=shop.Product&limit=5

API

  • GET /api/search/?q=query&models=app.Model,app.OtherModel&limit=10
  • GET /api/search/similar/app.Model/123/?limit=10

Admin UI

After install, open /admin/graph-search/ for full-text semantic search across your models.


CLI Commands

python manage.py build_search_index
python manage.py build_search_index --model shop.Product
python manage.py clear_search_index
python manage.py search_index_status

Python API

from django_graph_search import search, index, get_similar

results = search("red smartphone", models=["shop.Product"], limit=5)
index(product_instance)
similar = get_similar(product_instance, limit=5)

Delta Indexing Cache

Choose a cache backend to skip unchanged objects during reindexing:

  • file: local files at CACHE.OPTIONS.path
  • redis: Django cache backend (use CACHE.OPTIONS.alias)
  • db: Django DatabaseCache (use CACHE.OPTIONS.alias)

Why Django Graph Search

Most search solutions ignore relationships. This package builds rich context by traversing your model graph and makes it searchable with modern embeddings. It is fast, modular, and designed for production Django apps.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_graph_search-0.1.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_graph_search-0.1.0-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file django_graph_search-0.1.0.tar.gz.

File metadata

  • Download URL: django_graph_search-0.1.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for django_graph_search-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e766ad359341c42666efcba218bd7c0e483016a748c053b26b37a22a4b382a8b
MD5 bed5ceea135cbb1185064461e13473f0
BLAKE2b-256 c6785bfb642ee383edbee66d899bc8bc4f99710420cfc224378d80c7cf7038e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_graph_search-0.1.0.tar.gz:

Publisher: workflows.yaml on svalench/django_graph_search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file django_graph_search-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_graph_search-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85342833d171b54b3b08010a61d6a54c0a4df6549831765ba9e61370410a6dc7
MD5 d87fc759f5aad8589702361e1594e4a6
BLAKE2b-256 390d3741ebf36f915307b21ceb227fd47a66b9393e52eefa42ff6e0b2fc9f549

See more details on using hashes here.

Provenance

The following attestation bundles were made for django_graph_search-0.1.0-py3-none-any.whl:

Publisher: workflows.yaml on svalench/django_graph_search

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page