Configs2026年6月2日·1 分钟阅读

FlexSearch — Next-Generation Full-Text Search for Browser and Node.js

A high-performance full-text search library for JavaScript that runs in the browser and Node.js with zero dependencies.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
FlexSearch Overview
直接安装命令
npx -y tokrepo@latest install c35d50ee-5e19-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

FlexSearch is a full-text search library for JavaScript that provides memory-efficient indexing and sub-millisecond query performance. It runs in both browser and Node.js environments with zero external dependencies, making it suitable for client-side search in web applications and server-side indexing.

What FlexSearch Does

  • Indexes and searches text content with configurable tokenizers and scoring
  • Supports async processing and Web Worker offloading for non-blocking search
  • Provides document-based indexing with field-specific search and tag filtering
  • Enables persistent storage through export and import of index data
  • Offers multiple built-in language presets and custom encoder support

Architecture Overview

FlexSearch uses a context-based scoring algorithm that builds an inverted index with positional context for each indexed term. The library stores index data in a compact trie structure optimized for memory efficiency. Queries are resolved by intersecting matching result sets across context layers, with configurable resolution depth controlling the trade-off between precision and speed.

Self-Hosting & Configuration

  • Install via npm or include as a script tag for browser usage
  • Configure charset encoding, tokenizer mode (strict, forward, reverse, full), and resolution
  • Use the Document class for multi-field indexing with per-field options
  • Enable Web Worker mode by setting worker count in the constructor
  • Export index state to JSON for persistence and restore on application restart

Key Features

  • Sub-millisecond search on datasets with hundreds of thousands of documents
  • Context-based relevance scoring without external ranking dependencies
  • Built-in support for 12 languages with phonetic matching and accent handling
  • Zero dependencies and under 6 KB gzipped for the compact build
  • Incremental indexing with efficient add, update, and remove operations

Comparison with Similar Tools

  • Lunr.js — Simpler API but slower on large datasets and lacks Web Worker support
  • Fuse.js — Fuzzy search focused; not a full inverted index so less precise on exact matches
  • MiniSearch — Similar feature set but FlexSearch offers more tokenizer options and context scoring
  • Elasticsearch — Server-based distributed engine; overkill for client-side or embedded use cases

FAQ

Q: Can FlexSearch run entirely in the browser? A: Yes, it requires no backend and runs in any modern browser with optional Web Worker support.

Q: How large a dataset can FlexSearch handle? A: It efficiently indexes hundreds of thousands of documents in-memory; exact limits depend on available RAM.

Q: Does FlexSearch support fuzzy matching? A: It supports phonetic encoding and configurable tokenizer modes but is not primarily a fuzzy search library.

Q: Can I persist the index across page reloads? A: Yes, use the export/import methods to serialize the index to localStorage, IndexedDB, or a file.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产