0.0.2 • Published 8 years ago

index-segment v0.0.2

Weekly downloads
15
License
MIT
Repository
github
Last release
8 years ago

IndexSegment.js Build Status

A JS in memory search index.

Installation

$ npm install index-segment

Usage

//
// Basic usage usages the built in tokenizer
// which is pretty trivial and splits strings on
// non alpha numeric characters.
//
var IndexSegment = require('index-segment');

// create your index
var index = new IndexSegment();

// put(docText, docId)
index.put("hey-you", 1);
//> 2

index.put("hey you me", 2);
//> 3

index.search("me");
//> [2]

index.search("hey");
//> [1, 2]

Providing your own tokenizer.

The tokenizer is used during put and search methods.

var index = new IndexSegment(myTokenizer);

Development

Clone it :)

I'm using es6->es5 via babel, and polyfilling in Set and Map.

Run gulp for the es5 translation.

npm test for running the tests.

License

MIT

Author

Stan Rozenraukh