Whoosh-NG
Whoosh-NG is a modern, pure-Python full-text indexing and search library. Version 5.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]"
# Profiling tools (psutil, re2, pystemmer)
pip install "whoosh-ng[profiling]"
# Fast stemming with PyStemmer C backend
pip install "whoosh-ng[fast-stemming]"
# All optional features
pip install "whoosh-ng[vector,async,api,metrics,postgres,fuzzy,phonetic,profiling,fast-stemming]"
Development Installation
pip install "whoosh-ng[dev]"
Documentation
- Documentation — Full documentation site (English)
- API Reference — Complete module documentation
- Examples — Runnable code examples
- Data Sources — SQL, REST, GraphQL, CSV, JSON, Parquet data sources
- Changelog — Release notes and version history
- French Documentation — Documentation en français
- LLM-Friendly Docs:
llms.txt(index) |llms-full.txt(complete API)
Recent Changes in 5.4.0
Performance Highlights
| Gain | Scope | Notes |
|---|---|---|
| +68% indexing speed | 20k docs | analyzing phase reduced from 8.6s to 2.7s |
| +35% token creation | per-document | Token migrated to __slots__ |
| -93% write_block calls | 20k docs | Field cache inline in W3PostingsWriter |
| Compact postings | all segments | Single-posting and short-inline fast paths |
| Global compiled regex | RegexTokenizer |
Default pattern compiled once at module load |
| Stemmer provider | StemmingAnalyzer |
Select auto/internal/pystemmer backends |
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 - Data Sources (
whoosh_modern.data_sources):DataSourceprotocol withObservableDataSource,SQLSource(connection pooling, GROUP BY/JOIN/incremental sync),SQLAlchemySource,RESTSource(page/offset/cursor pagination + auth),GraphQLSource,FastCSVSource,JSONSource,ParquetSource,PandasSource,PolarsSource,PeeweeSource,TortoiseSource,PydanticSource, andDataSourceConfigfor declarative config from dict/JSON/YAML files - Schema Discovery (
whoosh_modern.schema_discovery): Result-set introspection with duplicate column detection and JSON/JSONB handling - FacetManager (
whoosh_modern.facets): Auto-discovery of facetable fields with manual override support - Validation Framework (
whoosh_modern.validation): 4-level validation (STRICT/WARN/SKIP/NONE) with typed exceptions and field context - Middleware Pipeline (
whoosh_modern.middleware):RetryMiddleware,LoggingMiddleware,CacheMiddlewarewith chainable pipeline - SearchView (
whoosh_modern.views): Unified interface integrating data sources, schema discovery, facets, validation, and middleware withbuild(),refresh(),reindex(),validate(),evolve_schema(), and strict mode - Stemmer Provider System (
whoosh_modern.analysis):get_stemmer(),register_stemmer(), auto-detection between internal Porter stemmer and PyStemmer C backend - Enhanced StemmingAnalyzer (
whoosh_modern.analysis): Acceptsstemmer="auto"|"internal"|"pystemmer"|providerparameter - Configuration Engine (
whoosh_modern.config):ConfigEnginewith hierarchical YAML/JSON merging, Pydantic models (WhooshNGConfig,FieldConfig), and sub-engines (SchemaEngine,AnalyzerEngine,DataSourceEngine,StorageEngine,SearchModelEngine,FacetEngine,PluginEngine,APIEngine) - Vector Search (
whoosh_modern.vector):HnswlibProviderfor HNSW approximate nearest neighbor search alongsideNumpyProvider - Embedding Framework (
whoosh_modern.embeddings):EmbeddingProviderprotocol andSentenceTransformersProviderfor sentence-transformers embeddings - Modern N-Gram Framework (
whoosh_modern.analysis):AutoCompleteAnalyzer,EdgeNgramAnalyzer,SEARCH_AS_YOU_TYPEfield type,NgramProfilerfor performance profiling, andAnalyzerPresets(autocomplete, partial_match, fuzzy, code_search, documentation, ecommerce, blog, multilingual) - Language Auto-Detection (
whoosh_modern.linguistics.detection):StopwordDetectorandLangDetectProviderfor automatic language detection with configurable supported languages - Language Registry (
whoosh_modern.linguistics.registry):LanguageRegistry,StemmerRegistry, andLanguageProfilefor centralized language/analyzer/stemmer resolution withget_default_registry() - Multi-Language Analyzer (
whoosh_modern.linguistics.analyzers):MultiLanguageAnalyzerapplies multiple language analyzers simultaneously for multilingual indexing - Analyzer Presets (
whoosh_modern.analysis.stemmer_presets):AnalyzerPresets.documentation(),.ecommerce(),.blog(),.multilingual()for common search scenarios - Explain Analyzer (
whoosh_modern.linguistics.explain):ExplainAnalyzer,AnalysisExplanation, andTokenExplanationexpose the tokenization/stemming pipeline for Search Studio - Cached Stemming Analyzer (
whoosh_modern.analysis.cached_stemming_analyzer):CachedStemmingAnalyzerwraps language analyzers with LRU caching (defaultcache_size=50000) for repeated tokens - Dictionary Stem Override (
whoosh_modern.linguistics.dictionary_stem_override):DictionaryStemOverrideallows overriding Snowball stemming with business dictionaries (JSON/Wiktionary) - Stemmer Profiler (
whoosh_modern.profiling.stemmer_profiler):StemmerProfilerandStemmerProfilerReportmeasure vocabulary reduction, estimated index size reduction, and average stemming time - Multilingual SearchApplication (
whoosh_modern.application):SearchApplicationnow acceptslanguage_detectoranddictionary_stem_overridesparameters;FieldConfigsupportslanguage="auto"with detector resolution
Breaking Changes
Re-indexing required. The on-disk posting format in
W3TermInfoand position/char encoding inFormatshas changed. Indexes created with pre-2.0 versions are not readable by this release. Delete old index directories and re-create them.
Tokennow uses__slots__: code that iteratestoken.__dict__should usetoken.copy()or slot introspection insteadfinish_postings()signature changed:allow_compact=Truekeyword addedwhoosh_modernpackage structure changed: Import paths for data sources have been updated. For example,from whoosh_modern.data_sources import SQLSourceshould now befrom whoosh_modern.data_sources.sql import SQLSource. Please update your import statements accordingly.- Import path change: The project was renamed from
whoosh-reloadedtowhoosh-ng. The modern extension modules previously available underwhoosh_reloadedare now importable underwhoosh_modern. Existing code usingwhoosh_reloadedmust be updated towhoosh_modern. Core Whoosh components remain available under thewhooshnamespace.
Changed
- Distribution is now
whoosh-ng(import namespace remainswhooshfor core components,whoosh_modernfor extensions) - Documentation links now absolute (GitHub Pages):
https://dorel14.github.io/whoosh-ng/en/... - 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: Data Sources
SQLSource — Index from a SQL database
from whoosh_modern.data_sources.sql import SQLSource
from whoosh import index
from whoosh.fields import Schema, TEXT, NUMERIC
import sqlite3
conn = sqlite3.connect("mydb.db")
source = SQLSource(
connection=conn,
query="SELECT * FROM products",
incremental_field="updated_at",
id_field="id",
)
# Discover schema from actual result metadata
schema = source.discover_schema()
# Build index with SearchView
from whoosh_modern.views import SearchView
view = SearchView(name="products", source=source)
ix = view.build("indexdir")
RESTSource — Index from a REST API
from whoosh_modern.data_sources.rest import RESTSource
source = RESTSource(
url="https://api.example.com/v2/products",
pagination="page",
page_size=50,
headers={"Authorization": "Bearer your_token"},
)
schema = source.discover_schema()
docs = list(source.iter_documents())
SearchView — Full pipeline integration
from whoosh_modern.views import SearchView
from whoosh_modern.data_sources.sql import SQLSource
import sqlite3
conn = sqlite3.connect("mydb.db")
source = SQLSource(
connection=conn,
query="SELECT * FROM reuters_articles",
incremental_field="article_date",
id_field="id",
)
view = SearchView(name="reuters", source=source)
ix = view.build("indexdir")
# Incremental refresh
count = view.refresh()
# Full reindex
count = view.reindex()
Example: Vector Search
pip install "whoosh-ng[vector]" numpy
from whoosh import index
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()
)
Metadata
Release files for whoosh-ng 5.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| whoosh_ng-5.4.0.tar.gz | 2.0 MB | Without provenance | Details for whoosh_ng-5.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| whoosh_ng-5.4.0-py3-none-any.whl | Python 3 | none | any | Details for whoosh_ng-5.4.0-py3-none-any.whl |
Total release size: 2.9 MB
Release files / whoosh_ng-5.4.0.tar.gz
| Download URL | whoosh_ng-5.4.0.tar.gz |
|---|---|
| Size | 2.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
56d76ba0bff79146575880768ad2fb13cfea53c66b413aa6f3200038f667704e
|
|
BLAKE2b-256 checksum How to use checksums |
c4b21e74e09932bf95e319c0ffa285702f5eb5c61d1138de600c18b5204c3bfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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-5.4.0-py3-none-any.whl
| Download URL | whoosh_ng-5.4.0-py3-none-any.whl |
|---|---|
| Size | 904.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1d3b43f6febecd409b5f72da93c6cbf5bd010e7f2ab103a94bf98abab65e09c4
|
|
BLAKE2b-256 checksum How to use checksums |
7309b9e8ab32afd97d8f0f800d3159de9afac117110b5df7ef0ec51cef496588
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|
Security for whoosh-ng 5.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.