Skip to main content

PyPI PyPI - Python Version License Documentation

Whoosh-NG

Whoosh-NG is a modern, pure-Python full-text indexing and search library. Version 4.0 brings a complete modernization with Python 3.11+ support, strict type annotations, optional feature profiles, and automated semantic releases.

Quick Start

  • Full-text search - BM25/BM25F scoring with phrase queries
  • Fielded documents - Structured indexing with typed fields
  • Query parsing - Flexible parser with boosting and syntax options
  • Facets & sorting - Group and sort results by any field
  • Highlighting - Snippet extraction with customizable formatters
  • Spell checking - Built-in spelling correction
  • Event-driven architecture - Plugin system with hooks and middleware
  • Optional extensions - Vector search, async, FastAPI, metrics, and more

Installation

Core Installation

pip install whoosh-ng

Optional Profiles

# Vector search with NumPy
pip install "whoosh-ng[vector]"

# Async wrappers
pip install "whoosh-ng[async]"

# FastAPI REST API integration
pip install "whoosh-ng[api]"

# Prometheus metrics
pip install "whoosh-ng[metrics]"

# PostgreSQL backend
pip install "whoosh-ng[postgres]"

# Fuzzy matching
pip install "whoosh-ng[fuzzy]"

# Phonetic search
pip install "whoosh-ng[phonetic]"

# All optional features
pip install "whoosh-ng[vector,async,api,metrics,postgres,fuzzy,phonetic]"

Development Installation

pip install "whoosh-ng[dev]"

Documentation

Recent Changes in 1.0.0

Added

  • Plugin System (whoosh.plugins): Plugin base class and PluginManager with entry-point auto-discovery, version validation, conflict detection, enable/disable, and dependency management
  • Registry System (whoosh.registry): Generic registry plus StorageRegistry, AnalyzerRegistry, RankingRegistry, SuggestRegistry, VectorRegistry, AutocompleteRegistry, and BackendRegistry
  • Middleware Pipeline (whoosh.middleware): Middleware base class (sync + async), MiddlewareContext, MiddlewareChain, MiddlewareRegistry, with official MetricsMiddleware, CacheMiddleware, CompressionMiddleware, EncryptionMiddleware, and PrometheusMiddleware
  • Event Bus (whoosh.event_bus): EventBus with subscribe/publish/clear
  • Hook System (whoosh.hooks): hookimpl, register_hook, call_hook
  • Backends: Backend ABC with lifecycle hooks, FileBackend, and SQLiteBackend
  • Provider Architecture: VectorProvider/VectorField, NumpyProvider for vector similarity search
  • Autocomplete Plugin (whoosh_modern.autocomplete): Inverted index and edge-ngram autocomplete
  • FastAPI Plugin (whoosh_fastapi): REST endpoints for search, autocomplete, vector search, and health checks
  • Admin UI Plugin (whoosh_admin): Dashboard for index administration
  • Entry Points: Auto-loaded plugins under whoosh.plugins group

Changed

  • Distribution renamed from whoosh-reloaded to whoosh-ng (import namespace remains whoosh)
  • Documentation site moved to GitHub Pages: https://dorel14.github.io/whoosh-ng/
  • Python 3.11+ required (dropped Python 3.9/3.10 support)
  • Packaging cleaned: consolidated extras in pyproject.toml
  • Type annotations modernized: mypy src/whoosh reports 0 errors, py.typed marker included

Example: Simple Search

from whoosh import index
from whoosh.fields import Schema, TEXT, ID
from whoosh.qparser import QueryParser

# Define schema
schema = Schema(
    id=ID(stored=True, unique=True),
    title=TEXT(stored=True),
    content=TEXT,
)

# Create index
ix = index.create_in("my_index", schema)

# Index documents
with ix.writer() as w:
    w.add_document(id="1", title="Hello World", content="Welcome to Whoosh-NG")
    w.add_document(id="2", title="Python Search", content="Fast text search library")

# Search
with ix.searcher() as s:
    qp = QueryParser("content", ix.schema)
    q = qp.parse("search library")
    results = s.search(q)
    for hit in results:
        print(hit["title"], hit.score)

Example: FastAPI Integration

from fastapi import FastAPI
from whoosh import index
from whoosh.fields import Schema, TEXT, ID
from whoosh_fastapi import create_app

schema = Schema(id=ID(), title=TEXT(), content=TEXT())
ix = index.create_in("docs", schema)

# Create FastAPI app with Whoosh-NG endpoints
app = create_app(ix, prefix="/api/v1")

# Endpoints available:
# GET  /api/v1/health          - Health check
# POST /api/v1/search          - Full-text search
# GET  /api/v1/autocomplete?q= - Autocomplete suggestions

Example: Vector Search

pip install "whoosh-ng[vector]" numpy
from whoosh.fields import Schema, TEXT, ID, VECTOR
from whoosh.vector import VectorField
from whoosh_modern.vector.plugin import VectorPlugin
from whoosh.plugins.manager import PluginManager
import numpy as np

# Create index with vector field
schema = Schema(
    id=ID(stored=True),
    title=TEXT(stored=True),
    embedding=VECTOR(dim=384),
)

# Register vector plugin
VectorPlugin().register(PluginManager())

# Index with embeddings
ix = index.create_in("vector_db", schema)
with ix.writer() as w:
    w.add_document(
        id="doc1",
        title="Python tutorial",
        embedding=np.random.rand(384).astype(np.float32).tobytes()
    )

Release files for whoosh-ng 1.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for whoosh-ng 1.3.1
File Size Uploaded
whoosh_ng-1.3.1.tar.gz 1.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for whoosh-ng 1.3.1
File Interpreter ABI Platform
whoosh_ng-1.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 1.8 MB

Release files / whoosh_ng-1.3.1.tar.gz

Download URL whoosh_ng-1.3.1.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
a20a710241bd941ac9765c0c78e18a52c4c7361bc7df6418c6e26f799b1c1665
BLAKE2b-256 checksum
How to use checksums
acf273916066d6f1856558e3b161241d41adacd7bbf16fb08a6fc4612e907979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / whoosh_ng-1.3.1-py3-none-any.whl

Download URL whoosh_ng-1.3.1-py3-none-any.whl
Size 643.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f00821bc291877dada853b84a1b48708b48fcb2f1eb8370fb4e97dfb78819f17
BLAKE2b-256 checksum
How to use checksums
0c0e70065879fcf4a94e8da864fd99d52d483c87a5bce3b6f3d12e1b79fe40b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

5.4.0

2 release files

5.3.1

2 release files

5.3.0

2 release files

5.2.0

2 release files

5.1.0

2 release files

5.0.0

2 release files

4.3.0

2 release files

4.2.3

2 release files

4.2.2

2 release files

4.2.1

2 release files

4.2.0

2 release files

4.1.0

2 release files

4.0.1

2 release files

4.0.0

2 release files

3.0.0

2 release files

2.0.0

2 release files

1.3.3

2 release files

1.3.2

2 release files

This release

1.3.1 This release

2 release files

1.3.0

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page