Files
modules/indexes-search/hyper-p2p-fulltext-lite/docs/architecture.md
T
2026-05-20 23:36:32 -04:00

1.1 KiB

Architecture: hyper-p2p-fulltext-lite

Category: indexes-search
Protocol: fulltext-lite/v1 (local-only)

Purpose

Provide minimal inverted-index full-text search for Bare/Pear without network replication.

Data structures

_docs: Map<docId, { id, text, tokens, at }>
_index: Map<term, Set<docId>>

Wire messages

type notes
No gossip or Protomux channel

Query pipeline

  1. tokenize(query) → terms[]
  2. For each term, load posting set (or empty)
  3. Intersect sets across terms
  4. Score each hit doc by matching term count
  5. Sort descending by score

Indexing pipeline

  1. Tokenize document body
  2. If id exists, remove old postings per previous tokens
  3. Insert new postings for each token
  4. Store document record

Lifecycle

new → addDocument/search → close (clear)

ready() is a no-op resolve.

Composition

Depends on ../../_shared/lib/errors.js only. No p2p-bare.js.

When to compose upstream

Pair with hyper-p2p-inverted-index when peers must share term postings, or with app-level Hyperbee persistence for durability.