texthill

0.1.6 • Public • Published

TextHill

A search engine written in typescript, can be used in the browser, with node.js and deno.

Look at this example below to get you started.

const bh = new BountyHunter(new MemoryStore());
const feed = async () => {
    await bh.feedDoc("hello world", "some hello world for feeding");

    const results = await bh.search("feeding"); 
}

Or remove the document from the index.

const bh = new BountyHunter(new MemoryStore());
bh.removeDoc("hello world").then(_ => console.log('succesfully removed'))

Write your own store to store your indexes where you prefer, extend from this abstract class.

export abstract class Store {

    abstract getItem(key: string, defaultValue?: any): Promise<any>;

    abstract setItem(key: string, data: any): Promise<void>;

    abstract removeItem(key: string): Promise<void>;

}

/// implement your own store
export class MyStore extends Store {
    ...
}
const bh = new BountyHunter(new MyStore());

You can also write your own stemmer or use snowball (look at node-snowball)

export abstract class Stemmer {
  
    abstract stem(ch: string): string;

}

const bh = new BountyHunter(new MyStore(), new Normalizer(new MyStemmer()));

Readme

Keywords

none

Package Sidebar

Install

npm i texthill

Weekly Downloads

1

Version

0.1.6

License

ISC

Unpacked Size

69.9 kB

Total Files

55

Last publish

Collaborators

  • jorishermans