1.0.16 • Published 2 years ago

node-index v1.0.16

Weekly downloads
13
License
MIT
Repository
github
Last release
2 years ago

node-index

A super simple search index based on Term Frequency–Inverse Document Frequency using the awesome natural module.

Useful when you only have a small set of files/strings to index, and want a usable, though limited search.

Recently updated with typescript support

Usage:

$ npm install node-index

or

$ yarn add node-index

Then build up an index in your code by calling addDocument(key, document) and search within the index using query(searchString):

import { Index } from 'node-index'

index = new Index()

index.addDocument("dog", {
    field1: "dog goes woof",
    field2: "woof woof woof"
})

index.addDocument("cow", {
    field1: "cow goes moo",
    field2: "moo moo moo"
})

// search for string 'string'
index.query("dog")

// returns sorted results by relevence in the form of:
[
    {
        key: 'dog',
        measure: 0.1337,
        doc: { /* original object you passed in */ }
    },
    ...
],

Liense

MIT

1.0.16

2 years ago

1.0.15

2 years ago

1.0.11

2 years ago

1.0.13

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

0.0.2

10 years ago

0.0.1

10 years ago