SearchFn

SearchFn

A full-text search engine and adapter system for TypeScript applications.

SearchFn is a full-text search engine for TypeScript applications. It ships its own search runtime — with BM25 scoring, inverted indexes, fuzzy matching, stemming, and a configurable text pipeline — that runs in-memory or in the browser via IndexedDB. The same adapter contract also connects to Postgres, Meilisearch, or Elasticsearch/OpenSearch, so you can choose the right runtime for your use case without changing application code.

System Architecture

SearchFn has two layers: a built-in search engine that handles indexing, tokenization, and ranking in-process, and backend adapters that delegate to external search services.

SearchFn is composed of four packages:

PackagePurpose
@searchfn/coreBuilt-in search engine — text pipeline, inverted index, BM25 scoring, fuzzy matching, stemming
@searchfn/adaptersAdapter contract and implementations — Memory and IndexedDB use the built-in engine; Postgres, Meilisearch, and Elasticsearch/OpenSearch delegate to external backends
@searchfn/clientClient with validation, defaults, and convenience constructors
@searchfn/serverHTTP server with authorization, structured logging, and secret redaction
@searchfn/datafn-providerBridge that maps any SearchAdapter into a DataFn SearchProvider

Built-in Engine vs External Backends

Built-in engine (Memory, IndexedDB)External backends (Postgres, Meilisearch, ES/OS)
Search logicSearchFn's own BM25 scoring, inverted index, fuzzy matching, stemmingDelegates to the backend's native search
InfrastructureZero — runs in-process or in the browserRequires running the external service
Use casesOffline-first apps, PWAs, browser-local search, in-process server search, testsMulti-client shared search, very large datasets, backend-specific features (facets, custom analyzers)

Both tiers are production-ready. The built-in engine powers offline-first apps and in-process search; external backends serve use cases that need shared state across clients or backend-specific capabilities. The adapter contract means you pick the right runtime for your requirements without changing application code.

Next Steps

  • Getting Started — install packages and run your first search in minutes.
  • Architecture — search engine internals, package layers, and adapter contract.
  • Client API — client constructors, methods, and validation.
  • Server API — HTTP endpoints, authorization, and limits.
  • Adapters — choose the right adapter for your use case.
  • DataFn Integration — connect SearchFn to DataFn.
  • Operations — deployment, security, observability, and troubleshooting.

Part of Super functions and built with care at 21n.