Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
JavaScript search libraries find matching records in a list of objects or documents without a search server. These libraries add search boxes to documentation sites, product catalogs, and offline apps that run entirely in the browser.
Popularity
Fuse.js has the most installs and the most GitHub stars.
Fuse.js is a fuzzy search library for small to medium datasets searched in the browser or on a server, with no dependencies. new Fuse takes an array of strings or objects and a keys list of fields to search. Calling search returns the matching items ranked by score. Matching uses the Bitap algorithm, an approximate string matcher, so queries with typos, misspellings, or partial words still find results. With useTokenSearch turned on, multi-word queries are ranked by relevance across all their words.
Downloads / mo
76.1M
Stars
20.5K
Last release
7.5.0
License
Apache-2.0
Strengths
Tolerates typos.Finds near matches when the query has typos, swapped letters, or missing characters.
Weights fields.Give title matches more weight than description matches.
Limitations
No index.Every search compares the query with every item. For larger datasets, FuseWorker splits the data across web workers, and an indexed library such as MiniSearch avoids the full scan.
Worker limits.FuseWorker can't take function-valued options, such as sortFn or getFn, because functions can't move to a worker.
Lunr builds a full-text search index of JSON documents in the browser. A lunr call takes a function that declares the fields, such as title and body, and adds each document. Searching with idx.search returns matching document references, each with a relevance score and the terms that matched. Indexes serialize to JSON. A site can build its index at deploy time and load the result in the browser instead of indexing on every visit. Queries can boost terms, scope to single fields, or match with wildcards and edit distance. Language support covers fourteen languages.
Downloads / mo
37.2M
Stars
9.2K
Last release
2.3.9
License
MIT
Strengths
Prebuilt indexes.Build the index during the site build and serve the serialized index to the browser.
Field boosts.Boost a field at build time so its matches rank higher.
Limitations
Immutable indexes.After an index is built, documents can't be added, updated, or removed. Changing the documents means rebuilding the index.
Wildcards skip stemming.A search term with a wildcard isn't stemmed. The term matches only its literal form.
var documents = [{
"name": "Lunr",
"text": "Like Solr, but much smaller, and not as bright."
}, {
"name": "React",
"text": "A JavaScript library for building user interfaces."
}, {
"name": "Lodash",
"text": "A modern JavaScript utility library delivering modularity, performance & extras."
}]
var idx = lunr(function () {
this.ref('name')
this.field('text')
documents.forEach(function (doc) {
this.add(doc)
}, this)
})
idx.search("bright")
function () {
if (language !== "en") {
if (Array.isArray(language)) {
// @ts-expect-error this.use(lunr.multiLanguage(...language));
} else {
// @ts-expect-error this.use(lunr[language]);
}
}
this.k1(k1);
this.b(b);
this.ref("id");
this.field("title");
this.field("content");
this.field("tags");
if (indexDocSidebarParentCategories > 0) {
this.field("sidebarParentCategories");
}
const that = this;
documents.forEach(
({
id,
sectionTitle,
sectionContent,
sectionTags,
docSidebarParentCategories,
}) => {
let sidebarParentCategories;
if (
indexDocSidebarParentCategories > 0 &&
docSidebarParentCategories
) {
sidebarParentCategories = [...docSidebarParentCategories]
.reverse()
.slice(0, indexDocSidebarParentCategories)
.join(" ");
}
that.add({
id: id.toString(), // the ref must be a string
title: sectionTitle,
content: sectionContent,
tags: sectionTags,
sidebarParentCategories,
});
},
);
}
MiniSearch
MiniSearch keeps a full-text index in memory, in the browser or in Node.js, with no external dependencies. new MiniSearch lists the fields to index and the fields to return with results. After addAll loads the documents, search supports exact, prefix, and fuzzy matching with field boosts. A separate method, autoSuggest, completes partial queries for search as the user types. Unlike Lunr, MiniSearch lets documents be added and removed at any time.
Downloads / mo
23.4M
Stars
6.2K
Last release
7.2.0
License
MIT
Strengths
Prefix and fuzzy search.Supports prefix search, fuzzy search, ranking, and field boosts in one index.
Saves indexes as JSON.Serialize the index to JSON and reload it later with MiniSearch.loadJSON.
Limitations
Index in memory.The index is stored in process memory. The indexed data has to fit in that memory.
Custom stemming.Stemming and stop words come from a processTerm function the project supplies.
import MiniSearch from 'minisearch'
const documents = [
{
id: 1,
title: 'Moby Dick',
text: 'Call me Ishmael. Some years ago...',
category: 'fiction'
},
{
id: 2,
title: 'Zen and the Art of Motorcycle Maintenance',
text: 'I can see by my watch...',
category: 'fiction'
},
{
id: 3,
title: 'Neuromancer',
text: 'The sky above the port was...',
category: 'fiction'
},
{
id: 4,
title: 'Zen and the Art of Archery',
text: 'At first sight it must seem...',
category: 'non-fiction'
},
]
let miniSearch = new MiniSearch({
fields: ['title', 'text'], // fields to index for full-text search
storeFields: ['title', 'category'] // fields to return with search results
})
miniSearch.addAll(documents)
let results = miniSearch.search('zen art motorcycle')
async function indexFile(page: string) {
const file = path.join(siteConfig.srcDir, page)
// get file metadata const fileId = getDocId(file)
const locale = getLocaleForPath(
siteConfig.site,
siteConfig.rewrites.map[page] || page
)
const index = getIndexByLocale(locale)
// retrieve file and split into "sections" let html: string
try {
html = await render(file, locale)
} catch (e) {
// in dev this runs unawaited, so a page that fails to render must not // reject and take the server down with it — the page reports the error // itself through the markdown transform siteConfig.logger.warn(
c.yellow(`Failed to index ${page} for search: ${(e as Error).message}`)
)
return
}
if (!html) return
const sections =
// user provided generator (await options.miniSearch?._splitIntoSections?.(file, html)) ??
// default implementation splitPageIntoSections(html)
// add sections to the locale index for await (const section of sections) {
if (!section || !(section.text || section.titles)) break
const { anchor, text, titles } = section
const id = anchor ? [fileId, anchor].join('#') : fileId
index.has(id) && index.discard(id)
index.add({
id,
text,
title: titles.at(-1)!,
titles: titles.slice(0, -1)
})
}
}
Orama
Orama is a search engine that runs in the browser, on a server, or at the edge, with full-text, vector, and hybrid search in one database. create sets a schema of typed fields. Documents go in through insert. A search call with a term returns ranked hits. Setting mode to vector compares a query embedding with a vector field instead. Filters, facets, geosearch, typo tolerance, and stemming in thirty languages come built in.
Downloads / mo
7.9M
Stars
10.6K
Last release
3.1.18
License
Apache-2.0
Strengths
Field boosts.Boost a field so its matches rank higher.
Vector search built in.Vector, full-text, and hybrid queries use the same search function.
Limitations
Embeddings from outside.Vector queries need embeddings at insert and search time, from the project's own model or from the @orama/plugin-embeddings plugin.
Fixed vector size.Each vector field declares its dimension count when the database is created.
FlexSearch builds full-text indexes for the browser and Node.js. Three index types cover different jobs: Index stores id and text pairs, Document indexes multi-field JSON documents, and Worker runs an index in a background thread. The tokenize option sets how partial words match. With forward, a query for flex finds flexsearch, while full indexes every substring at a much higher memory cost. Indexes stay in memory by default, and persistent indexes can store them in IndexedDB, Redis, SQLite, Postgres, MongoDB, or ClickHouse.
Downloads / mo
5.3M
Stars
13.8K
Last release
0.8.212
License
Apache-2.0
Strengths
Tokenizer controls matching.Choose a tokenizer so that typing flex or search finds flexsearch.
Worker threads.Run index updates and queries in parallel worker threads.
Limitations
Tokenizer sets memory.Broader partial matching multiplies index size. The README recommends the narrowest tokenizer that covers the queries users type.
Async workers.Every method on a Worker index returns a promise or takes a callback.
Js Search indexes JavaScript and JSON objects for client-side search, with no third-party dependencies. new JsSearch.Search takes the field that identifies each document. Next, addIndex adds each field to search, including nested ones such as an author's name, and addDocuments loads the objects. Results rank by TF-IDF, a term-weighting score, unless the project switches to an unordered index. The index strategy sets what matches: word prefixes by default, exact words, or every substring. The library began as a lighter implementation of Lunr.
Downloads / mo
849.5K
Stars
2.2K
Last release
2.0.1
License
MIT
Strengths
Choice of index strategy.Index word prefixes by default, or switch to exact words or every substring.
No dependencies.It runs on ES5 and needs no third-party libraries.
Limitations
Stemming from another library.Stemming comes from a third-party stemmer, such as porter-stemmer, wrapped in a StemmingTokenizer.
Ranking costs time.Switching to UnorderedSearchIndex turns off TF-IDF ranking and returns results in no particular order.
rebuildIndex = () => {
const { bookList } = this.state
const dataToSearch = new JsSearch.Search(`isbn`)
/**
* defines a indexing strategy for the data
* more more about it in here https://github.com/bvaughn/js-search#configuring-the-index-strategy
*/
dataToSearch.indexStrategy = new JsSearch.PrefixIndexStrategy()
/**
* defines the sanitizer for the search
* to prevent some of the words from being excluded
*
*/
dataToSearch.sanitizer = new JsSearch.LowerCaseSanitizer()
/**
* defines the search index
* read more in here https://github.com/bvaughn/js-search#configuring-the-search-index
*/
dataToSearch.searchIndex = new JsSearch.TfIdfSearchIndex(`isbn`)
dataToSearch.addIndex(`title`) // sets the index attribute for the data
dataToSearch.addIndex(`author`) // sets the index attribute for the data
dataToSearch.addDocuments(bookList) // adds the data to be searched
this.setState({ search: dataToSearch, isLoading: false })
}
wink-bm25-text-search
wink-bm25-text-search builds an in-memory search index from JSON documents, in Node.js or the browser, ranked by a probabilistic relevance algorithm. defineConfig sets a weight for each field. Next, definePrepTasks sets the text preparation, such as tokenizing and stemming with wink-nlp, and addDoc adds documents. A call to consolidate finalizes the index before search runs. A negative field weight lowers a document's score when a query term appears in that field.
Downloads / mo
277.9K
Stars
74
Last release
3.1.2
License
MIT
Strengths
Field weights can be negative.Set a weight per field. A negative weight pushes down documents that match in that field.
Pluggable text preparation.Plug in wink-nlp for stemming, stop-word removal, and negation handling.
Limitations
Closed after consolidation.No documents can be added after consolidate. The README suggests exporting JSON before consolidating, then importing it to add more.
Setup order.defineConfig and definePrepTasks must run before any document is added.
public async queryItems<TItemMetadata extends TMetadata = TMetadata>(
vector: number[],
query: string,
topK: number,
filter?: MetadataFilter,
isBm25?: boolean
): Promise<QueryResult<TItemMetadata>[]> {
await this.loadIndexData();
// Filter items let items = this._data!.items;
if (filter) {
items = items.filter(i => ItemSelector.select(i.metadata, filter));
}
// Find top K by cosine similarity using a bounded min-heap of size K. // For N items this is O(N log K) vs the previous O(N log N) full sort. const norm = ItemSelector.normalize(vector);
const k = Math.min(topK, items.length);
const heap: { index: number; distance: number }[] = [];
const siftUp = (start: number) => {
let i = start;
while (i > 0) {
const parent = (i - 1) >> 1;
if (heap[parent].distance > heap[i].distance) {
const tmp = heap[parent]; heap[parent] = heap[i]; heap[i] = tmp;
i = parent;
} else break;
}
};
const siftDown = () => {
let i = 0;
const n = heap.length;
while (true) {
const l = (i << 1) + 1;
const r = l + 1;
let smallest = i;
if (l < n && heap[l].distance < heap[smallest].distance) smallest = l;
if (r < n && heap[r].distance < heap[smallest].distance) smallest = r;
if (smallest === i) break;
const tmp = heap[i]; heap[i] = heap[smallest]; heap[smallest] = tmp;
i = smallest;
}
};
for (let i = 0; i < items.length; i++) {
const distance = ItemSelector.normalizedCosineSimilarity(vector, norm, items[i].vector, items[i].norm);
if (heap.length < k) {
heap.push({ index: i, distance });
siftUp(heap.length - 1);
} else if (k > 0 && distance > heap[0].distance) {
heap[0] = { index: i, distance };
siftDown();
}
}
heap.sort((a, b) => b.distance - a.distance);
// Find top k const top: QueryResult<TItemMetadata>[] = heap.map(d => {
return {
item: Object.assign({}, items[d.index]) as any,
score: d.distance
};
});
// Load external metadata in parallel — each file is independent, and the // top-K size is small, so this is bounded fan-out. await Promise.all(top.map(async (item) => {
if (item.item.metadataFile) {
const metadataPath = path.join(this._folderPath, item.item.metadataFile);
const metadataBuffer = await this.storage.readFile(metadataPath);
item.item.metadata = this._codec.deserializeMetadata(metadataBuffer) as any;
}
}));
// Perform bm25 search only if enabled. Avoid duplicate chunks that are already selected during semantic search. if (isBm25) {
const itemSet = new Set<string>();
for (const r of top) itemSet.add(r.item.id);
// Set up BM25 engine await this.setupBm25();
// Add docs if we have necessary metadata; guard everything to avoid crashes for (let i = 0; i < items.length; i++) {
if (!itemSet.has(items[i].id)) {
const item = items[i] as any;
const md = item.metadata || {};
if (md.documentId != undefined && md.startPos != undefined && md.endPos != undefined) {
try {
const currDocTxt = await this._docReader(String(md.documentId));
const startPos = Number(md.startPos);
const endPos = Number(md.endPos);
const chunkText = currDocTxt.substring(startPos, endPos + 1);
this._bm25Engine.addDoc?.({ body: chunkText }, i);
} catch {
// Ignore load or engine errors for BM25 doc prep }
}
}
}
this._bm25Engine.consolidate?.();
const results: any[] = await this.bm25Search(query, items, topK);
results.forEach((res: any) => {
// Support both [index, score] tuples and { item, score } objects if (Array.isArray(res)) {
const idx = res[0];
const score = res[1];
if (items[idx]) {
top.push({
item: Object.assign({}, { ...items[idx], metadata: { ...items[idx].metadata, isBm25: true } }) as any,
score
});
}
} else if (res && typeof res === 'object' && 'item' in res && 'score' in res) {
const objItem = Object.assign({}, { ...(res.item || {}), metadata: { ...(res.item?.metadata || {}), isBm25: true } }) as any;
top.push({ item: objItem, score: res.score });
}
});
}
return top;
}
FAQ
Use MiniSearch to search app documents, especially ones users add or edit. Use Fuse.js for typo-tolerant matching over a short list, and Lunr for a static site whose index is built ahead of time. Choose Orama when an app also needs vector search.
MiniSearch is a full-text search engine that keeps its index in memory, in the browser or in Node.js. It supports prefix search, fuzzy search, and field boosts, and documents can be added or removed at any time.
FlexSearch is a full-text search library, tuned through its tokenizer and scalable with worker threads. Its persistent indexes keep the index in IndexedDB, Redis, SQLite, or another database instead of memory.
Use Fuse.js to fuzzy-match a short list of names or labels. For larger document sets, turn on the fuzzy option in MiniSearch, which scales the allowed edit distance with the length of each term.
Orama is a search engine written in TypeScript that runs full-text, vector, and hybrid search over a custom schema. It works in the browser, on a server, or at the edge.
Yes, for static sites: build the index at deploy time and load it in the browser. A Lunr index can't change after it's built, and the last release was in Aug 2020, so use MiniSearch when documents change while the app runs.
For coding agents
Found your full-text search library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.