Skip to content

API Reference parrot.knowledge.wiki.search

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.knowledge.wiki.search

View source

Combined search for the LLM Wiki (FEAT-260 + WikiStore plane).

Preferred path — when a :class:WikiStore is provided, every query is answered directly from the single-file SQLite plane (no toolkit fan-out, no markdown parsing at query time):

  • lexical — FTS5/BM25 over title/summary/body.
  • vector — cosine over stored page embeddings (requires an embedder callable).
  • "combined" (default) merges both with configurable weights. Legacy mode names map onto the plane: "pageindex" → lexical, "graphindex" → vector.

Legacy path — without a store, results are merged from PageIndexToolkit.search() and GraphIndexToolkit.search_hybrid() exactly as before (kept for one release).

Results from each group are min-max normalised to [0, 1], weighted by the configurable search_weights dictionary, deduplicated by node_id, and returned as a sorted :class:WikiSearchResult list.

Alias BaseWikiStore

Re-exported from parrot.knowledge.wiki.store.BaseWikiStore.

Class WikiCombinedSearch

Unified search across PageIndex and GraphIndex.

Example::

cs = WikiCombinedSearch(pi_toolkit, gi_toolkit)
results = await cs.search("neural networks", mode="combined", top_k=10)
Parameter Type Default Description
pageindex_toolkit Any A PageIndexToolkit instance (legacy path only — unused when store is provided).
graphindex_toolkit Any A GraphIndexToolkit instance (legacy path only).
default_weights Optional[dict[str, float]] None Optional weighting dict. Accepts the new keys "lexical" / "vector" or the legacy aliases "pageindex" / "graphindex". Defaults to {"pageindex": 0.6, "graphindex": 0.4}.
store Optional[BaseWikiStore] None :class:BaseWikiStore retrieval plane. When provided, all searches run against it (preferred path).
embedder Optional[Callable[[str], Awaitable[list[float]]]] None Optional async text -> vector callable used for the vector leg of store-backed search.
normalize_store_rows bool True

Attributes:

Attribute Type Description
logger logging.Logger Standard Python logger.

Method WikiCombinedSearch.search

Search the wiki and return merged, ranked results.

search(query: str, mode: str = 'combined', top_k: int = 10, tree_name: Optional[str] = None, weights: Optional[dict[str, float]] = None, include_archived: bool = False) -> list[WikiSearchResult]

Parameter Type Default Description
query str Natural-language search query.
mode str 'combined' One of "combined", "pageindex", or "graphindex". Unknown modes default to "combined".
top_k int 10 Maximum results to return per backend (before merging).
tree_name Optional[str] None Optional PageIndex tree name to scope the search. When None, the PageIndex toolkit searches all trees.
weights Optional[dict[str, float]] None Optional per-call override for score weights. Falls back to self._weights when None.
include_archived bool False When False (the default), pages in the supervised-ingestion "archive" category (FEAT-402) are excluded from the results — they are indexed and retrievable but opt-in only. Set True to include them alongside everything else. No-op on the legacy (storeless) path, which predates the archive category.

Returns: list[WikiSearchResult] — Sorted list of :class:WikiSearchResult objects (descending by score). May be empty if no backends returned results.

Method WikiCombinedSearch.find_related

Discover pages related to a given wiki page via graph traversal.

Prefers GraphIndexToolkit.get_neighborhood(node_id, depth) when available. Falls back to search_hybrid(page_id) to approximate neighbourhood retrieval when get_neighborhood is absent — this guards against runtimes where the method has not been implemented yet.

find_related(page_id: str, depth: int = 2) -> list[dict[str, Any]]

Parameter Type Default Description
page_id str GraphIndex node ID of the page to explore from.
depth int 2 Maximum traversal depth (hops) from the seed node.

Returns: list[dict[str, Any]] — A list of neighbour node dicts. Returns an empty list on error.

Alias WikiPageCategory

Re-exported from parrot.knowledge.wiki.models.WikiPageCategory.

Alias WikiSearchResult

Re-exported from parrot.knowledge.wiki.models.WikiSearchResult.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally