Skip to main content

API Overview

This section provides a comprehensive reference of the Whoosh-NG public API.

Modules​

ModuleDescription
whoosh.indexHigh-level index creation, opening, and management
whoosh.fieldsSchema and field type definitions
whoosh.writingWriter classes and merge policies
whoosh.searchingSearcher, Results, and collectors
whoosh.queryQuery classes and parsers
whoosh.qparserQuery parser implementation
whoosh.analysisTokenizers, filters, and analyzers
whoosh.highlightSearch result highlighting
whoosh.spellingSpelling correction
whoosh.sortingFacets and sorting
whoosh.event_busEvent system
whoosh.hooksHook system
whoosh.middlewareMiddleware pipeline
whoosh.pluginsPlugin system and registry
whoosh.backendsStorage backends
whoosh.vectorVector search providers
whoosh_modern.autocompleteAutocomplete providers
whoosh_fastapiFastAPI integration

Quick Reference​

Index Lifecycle​

from whoosh.index import create_in, open_dir, exists_in

# Create
ix = create_in("indexdir", schema)

# Open
ix = open_dir("indexdir")

# Check
if exists_in("indexdir"):
ix = open_dir("indexdir")

Writing​

with ix.writer() as writer:
writer.add_document(field1=value1, field2=value2)
writer.commit()

Reading​

from whoosh.qparser import QueryParser

with ix.searcher() as searcher:
qp = QueryParser("content", ix.schema)
q = qp.parse("query")
results = searcher.search(q)

Schema​

from whoosh.fields import Schema, TEXT, ID, NUMERIC

schema = Schema(
title=TEXT(stored=True),
path=ID(stored=True, unique=True),
count=NUMERIC(int, stored=True)
)