0.1.5 • Published 11 days ago

ltl-search v0.1.5

Weekly downloads
-
License
MIT
Repository
gitlab
Last release
11 days ago

ltl-search

Getting started

yarn add ltl-search

Usage

Hook

import { useBM25Search } from 'ltl-search';

const { analysisDocs, search } = useBM25Search();

useEffect(() => {
  analysisDocs([
    { id: 'test1', message: 'test 1' },
    { id: 'test2', message: 'test 2' },
    { id: 'test3', message: 'Hello' },
    { id: 'test4', message: 'Hel' },
    { id: 'test5', message: 'Hi' },
  ]);
}, []);

// Test
cont results1 = search('test'); // return test 1, test 2
cont results2 = search('H'); // return Hello, Hel, Hi
cont results3 = search('Hello'); // return Hello
cont results4 = search('Hel'); // return Hello, Hel
cont results5 = search('Hi'); // return Hi

Function

import { BM25Search } from 'ltl-search';

const { analysisDocs, search } = BM25Search();
analysisDocs([
  { id: 'test1', message: 'test 1' },
  { id: 'test2', message: 'test 2' },
  { id: 'test3', message: 'Hello' },
  { id: 'test4', message: 'Hel' },
  { id: 'test5', message: 'Hi' },
]);

// Test
cont results1 = search('test'); // return test 1, test 2
cont results2 = search('H'); // return Hello, Hel, Hi
cont results3 = search('Hello'); // return Hello
cont results4 = search('Hel'); // return Hello, Hel
cont results5 = search('Hi'); // return Hi
0.1.2

13 days ago

0.1.4

13 days ago

0.1.3

13 days ago

0.1.5

11 days ago

0.1.1

2 months ago