@pacote/bloom-search
TypeScript icon, indicating that this package has built-in type declarations

0.17.3 • Public • Published

@pacote/bloom-search

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.

See a how several client-side search engines compare against Bloom Search.

Installation

yarn add @pacote/bloom-search

Example

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 }])

License

MIT © Luís Rodrigues.

Readme

Keywords

Package Sidebar

Install

npm i @pacote/bloom-search

Weekly Downloads

1

Version

0.17.3

License

MIT

Unpacked Size

116 kB

Total Files

41

Last publish

Collaborators

  • goblindegook