gitmyhub

minisearch

TypeScript ★ 6.0k updated 9mo ago

Tiny and powerful JavaScript full-text search engine for browser and Node

MiniSearch is a tiny JavaScript library that adds instant full-text search to any web app or server without an external service, the entire index lives in memory for real-time, as-you-type results.

TypeScriptJavaScriptNode.jssetup: easycomplexity 2/5

MiniSearch is a JavaScript library that adds full-text search to a web application or Node.js server without needing any external search service. It stores the entire search index in memory, which means searches happen instantly and the app does not need to send requests to a separate server to get results. This makes it well suited for real-time "search as you type" features where speed matters.

The library works by taking a set of documents you provide, indexing the fields you care about (such as a title or a body of text), and then letting you run searches against those documents. Search results are ranked by relevance. It supports several types of search: exact word matching, prefix matching (so a partial word like "moto" matches "motorcycle"), and fuzzy matching (which tolerates small spelling mistakes). You can also boost certain fields so that a match in the title counts more than a match in the body text, and filter results by any property on your documents.

There is also an auto-suggestion feature: give it a partial query and it returns ranked completion suggestions, which is the backbone of a search-as-you-type autocomplete input. Documents can be added or removed from the index at any time without rebuilding it from scratch.

The library has no external dependencies and is small in size, which is important for browser use where download size affects page load time. It can be installed via npm or yarn, or loaded directly in a browser via a script tag from a CDN.

MiniSearch is a code library, not a standalone application, so it is intended for developers building web apps or server-side applications that need search functionality over a dataset that fits in memory. It is not a replacement for large-scale search infrastructure; it is designed for collections that are small enough to keep in RAM on a single machine or in a browser tab.

Where it fits