Skip to main content

Augment existing database tables with vector and BM25 search

Project description

dot-search

Python Version

dot-search augments existing database tables with vector search, BM25 keyword search, and exact substring matching. Results from multiple strategies are fused via Reciprocal Rank Fusion (RRF).

Prerequisites

PostgreSQL (production)

Requires pgvector and ParadeDB pg_search:

CREATE EXTENSION vector;
CREATE EXTENSION pg_search;

SQLite (testing only)

Uses sqlite-vec. No BM25 support.

Install

pip install dot-search

Environment variables

Variable Example
DOT__EMBED_API_KEY Bearer token
DOT__EMBED_BASE_URL https://api.openai.com/v1
DOT__EMBED_MODEL text-embedding-3-small
DOT__EMBED_DIMENSION 1536

Works with any OpenAI-compatible API (OpenAI, vLLM, TGI, Ollama, etc.).

Usage

import asyncio
from dot_search import (
    SearchEngine, TableConfig, EmbeddingConfig,
    BM25Config, ExactConfig, SearchConfig,
)

engine = SearchEngine(db_url="postgresql+asyncpg://user:pass@localhost/mydb")

async def main():
    # --- 1. Index a table with vector search ---
    await engine.index(TableConfig(
        table="articles",
        embeddings=[
            EmbeddingConfig(key="body", source_column="body"),
        ],
    ))

    # --- 2. Search ---
    results = await engine.search("neural networks", "articles")
    for r in results:
        print(r.id, r.score)

    # --- 3. Multi-strategy index ---
    await engine.index(TableConfig(
        table="articles",
        embeddings=[
            EmbeddingConfig(key="body", source_column="body"),
            EmbeddingConfig(key="title", source_column="title"),
        ],
        bm25=[
            BM25Config(key="title_bm25", source_column="title"),
            BM25Config(key="body_bm25", source_column="body"),
        ],
        exact=[ExactConfig(key="name_exact", source_column="name")],
    ))

    # --- 4. Hybrid search with SQL filter and weight overrides ---
    results = await engine.search(
        "fermentation and gut health",
        "articles",
        SearchConfig(
            limit=10,
            where="published_year >= 2022 AND topic = 'health'",
            weights={"body": 1.0, "title": 0.3, "title_bm25": 0.5, "body_bm25": 2.0},
        ),
    )

    # --- 5. Single-strategy search ---
    results = await engine.search("fermentation", "articles", SearchConfig(strategy="bm25"))
    results = await engine.search("Dupont", "articles", SearchConfig(strategy="exact"))

    # --- 6. Multiple indexes on the same table ---
    await engine.index(TableConfig(
        table="articles",
        index_id="article_titles",
        embeddings=[EmbeddingConfig(key="title_only", source_column="title")],
    ))
    results = await engine.search("gut health", "article_titles")

asyncio.run(main())

Search strategies

Strategy What it uses
"hybrid" Vector + BM25 + exact (any configured), fused via RRF (default)
"vector" Vector similarity only
"bm25" BM25 keyword search only
"exact" Substring (LIKE) search only

Contributing & Development

See docs/CONTRIBUTING.md and docs/DEVELOPMENT.md.

License

See LICENSE for details.

Contact

deepika Team — contact@deepika.ai Project: gitlab.com/deepika6190303/deepika-open-toolbox/dot-search

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

dot_search-0.3.0.tar.gz (65.4 kB view details)

Uploaded Source

Built Distribution

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

dot_search-0.3.0-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

Details for the file dot_search-0.3.0.tar.gz.

File metadata

  • Download URL: dot_search-0.3.0.tar.gz
  • Upload date:
  • Size: 65.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dot_search-0.3.0.tar.gz
Algorithm Hash digest
SHA256 7255dcf5e3d887fafacade1262ea5d69bf488354be8e6213b0754c980ad1a742
MD5 45ffe16a91752df81be0bd1e5e2188e7
BLAKE2b-256 1559942b5a865156a1b58e75392f43c46b8ec44d71e249fe3e102320a6384e1d

See more details on using hashes here.

File details

Details for the file dot_search-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: dot_search-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dot_search-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 db4417d8c809d73c9c8fee087d1bf5b4496dd2f7107fe04efbe8605ac124cf42
MD5 2741a5c374dd7dd688c2ea85d639d354
BLAKE2b-256 c927ba33888126fd6d0b9616e8d990c469c8223ac0be77aea191be00566ae5a7

See more details on using hashes here.

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