Getting Started
Last updated:
LumoSearch is an open-source full-text search engine for JavaScript and TypeScript that delivers ranked, typo-tolerant results in under 5ms. Install the ~8KB library, define which fields to search, and get BM25F-ranked results with a single function call — no external services required.
Installation
Install LumoSearch via npm, yarn, or pnpm:
npm install @lumosearch/searchyarn add @lumosearch/searchpnpm add @lumosearch/searchQuick Start
Here's a minimal example to get you started:
import { LumoSearch } from '@lumosearch/search'
const docs = [
{
title: 'JavaScript Patterns',
body: 'Reusable design patterns for JavaScript.',
category: 'books'
},
{
title: 'TypeScript Handbook',
body: 'Core TypeScript syntax and type system.',
category: 'docs'
},
{
title: 'Node.js in Action',
body: 'Server-side JavaScript with Express.',
category: 'books'
}
]
const search = new LumoSearch(docs, {
keys: [
{ name: 'title', weight: 3 },
{ name: 'body', weight: 1 }
],
candidateLimit: 250,
limit: 10
})
const results = search.search('javscrippt paterns')
// => [{ item: { title: 'JavaScript Patterns', ... }, score: 0.94, ... }]Configuration Options
The LumoSearch constructor accepts two arguments:
- docs — Array of documents to index
- options — Configuration object
Basic Options
| Option | Type | Default | Description |
|---|---|---|---|
| keys | Array | [] | Fields to search with optional weights |
| limit | number | 10 | Maximum results to return |
| candidateLimit | number | 250 | Candidates before ranking |
| synonyms | Object | Token aliases for expansion |
Frequently Asked Questions
How do I install LumoSearch?
Install via npm (npm install @lumosearch/search), yarn (yarn add @lumosearch/search), or pnpm (pnpm add @lumosearch/search). LumoSearch has zero dependencies and works in Node.js and browsers.
Does LumoSearch handle typos and misspellings?
Yes. LumoSearch uses trigram-based fuzzy matching to tolerate typos. For example, searching 'javscrippt paterns' correctly matches 'JavaScript Patterns' with a relevance score of 0.94.
How fast is LumoSearch?
LumoSearch returns results in under 5ms for datasets up to 100K documents. It uses inverted indexes and candidate pruning to avoid scoring every document, unlike libraries like Fuse.js that scan linearly.
Can I use LumoSearch with React, Vue, or Svelte?
Yes. LumoSearch is a plain JavaScript/TypeScript library with no framework dependencies. It works in any frontend framework or server-side in Node.js.
What is the difference between LumoSearch and Fuse.js?
LumoSearch uses inverted indexes and BM25F ranking for relevance, while Fuse.js uses linear scanning and approximate string matching. LumoSearch is faster on large datasets and produces more relevant results through field weighting and IDF-based scoring.