nanosearch
v1.0.0
Published
A tiny search engine.
Downloads
1
Readme
nanosearch
A tiny search engine.
Suitable for in-browser use, this provides n-gram based search results.
Quickstart
import { SearchEngine } from '@toastdriven/nanosearch';
// Create a search engine.
const engine = new SearchEngine();
// Index some documents.
// First parameter is the unique document ID, second is the document text.
engine.add("abc", "The dog is a 'hot dog'.");
engine.add("def", "Dogs > Cats");
engine.add("ghi", "the quick brown fox jumps over the lazy dog");
engine.add("jkl", "Am I lazy, or just work smart?");
// Then, you can let the user search on the engine...
engine.search("my dog");
// ...including limiting results (to just one)...
engine.search("lazy", 1);
// ...or a second page of ten results!
engine.search("dogs", 10, 2);
Installation
$ npm install @toastdriven/nanosearch
Requirements
- ES6 (or similar translation/polyfill)
Tests
$ git clone [email protected]:toastdriven/nanosearch.git
$ cd nanosearch
$ npm install
$ npm test
Docs
$ git clone [email protected]:toastdriven/nanosearch.git
$ cd nanosearch
$ npm install
$ ./node_modules/.bin/jsdoc -r -d ~/Desktop/out --package package.json --readme README.md src
License
New BSD