TypeScript icon, indicating that this package has built-in type declarations

0.13.0 • Public • Published


version minified minified + gzip

Document search using Bloom filters.

This module was created to support basic full-text search on static sites where a backend-supported search feature isn't possible, and loading a complete index on the client is too expensive.

Bloom filters are used because they trade result accuracy for space efficiency. With them, false positive matches are possible, but false negatives are not. That is to say, its responses are either a certain miss or a possible match.

They allow building a simple document search index that is smaller than inverted indices at the cost of occasionally returning matches for words that are not present in any document. This error rate can be adjusted to improve search quality.

Due to the limitations inherent in Bloom filters, only full, individual words can be matched against indexed documents while searching. The absence of partial matching can be remedied through the use of a custom stemmer function, but more "advanced" features like suffix matching cannot be performed at all.


yarn add @pacote/bloom-search


import { BloomSearch } from '@pacote/bloom-search'

const bs = new BloomSearch({
  fields: ['text'],
  summary: ['id'],

bs.add('id1', { id: 1, text: 'foo bar' })
bs.add('id2', { id: 2, text: 'foo baz' })

bs.search('foo +bar') // => [{ id: 1 }])
bs.search('foo -bar') // => [{ id: 2 }])


MIT © Luís Rodrigues.


npm i @pacote/bloom-search

DownloadsWeekly Downloads






Unpacked Size

100 kB

Total Files


Last publish


  • goblindegook