ltl-search
v0.1.5
Published
ltl-search
Downloads
8
Maintainers
Readme
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