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
- API Reference - Complete module documentation
- User Guides - Tutorials and best practices
- Examples - Runnable code examples
- French Documentation - Documentation en français
Recent Changes in 1.0.0
Added
- Plugin System (
whoosh.plugins):Pluginbase class andPluginManagerwith entry-point auto-discovery, version validation, conflict detection, enable/disable, and dependency management - Registry System (
whoosh.registry): Generic registry plusStorageRegistry,AnalyzerRegistry,RankingRegistry,SuggestRegistry,VectorRegistry,AutocompleteRegistry, andBackendRegistry - Middleware Pipeline (
whoosh.middleware):Middlewarebase class (sync + async),MiddlewareContext,MiddlewareChain,MiddlewareRegistry, with officialMetricsMiddleware,CacheMiddleware,CompressionMiddleware,EncryptionMiddleware, andPrometheusMiddleware - Event Bus (
whoosh.event_bus):EventBuswith subscribe/publish/clear - Hook System (
whoosh.hooks):hookimpl,register_hook,call_hook - Backends:
BackendABC with lifecycle hooks,FileBackend, andSQLiteBackend - Provider Architecture:
VectorProvider/VectorField,NumpyProviderfor 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.pluginsgroup
Changed
- Distribution renamed from
whoosh-reloadedtowhoosh-ng(import namespace remainswhoosh) - 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/whooshreports 0 errors,py.typedmarker 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.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| whoosh_ng-1.2.2.tar.gz | 1.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| whoosh_ng-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.8 MB
Release files / whoosh_ng-1.2.2.tar.gz
| Download URL | whoosh_ng-1.2.2.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaa596092a7c39f5d020177cfd7c85bcca8db3cbd96977c7688884d79e796fa8
|
|
BLAKE2b-256 checksum How to use checksums |
6d6e0ac8ff2ad0897f8cbb260ef462fc8a377dbdbe75e0460eed32b1d3369352
|
| 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.2.2-py3-none-any.whl
| Download URL | whoosh_ng-1.2.2-py3-none-any.whl |
|---|---|
| Size | 643.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c3a2e0b984b3c651508c13ddd6fd149a075852e4aeaa9097f2f772e69302761f
|
|
BLAKE2b-256 checksum How to use checksums |
e8d1805aa5229af60f7c2825be5360951a26d35caa5f29184023bbf853529b23
|
| 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}
|