monolieta-search
TypeScript icon, indicating that this package has built-in type declarations

1.2.3 • Public • Published

Coverage Status

Monolieta-Search

Search library for browser and Node.js

Getting started

Install monolieta-search using yarn or npm

yarn add monolieta-search
npm install monolieta-search

Usage

import { Search } from 'monolieta-search';

const client = new Search();
client.index('001', 'The Lord of the Rings');
client.index('002', 'The Hobbit');

client.search('the hobbit'); // ["002", "001"]

Setting

Name Type Default
caseSensitive boolean false
exactWordStrategy boolean false
ignoreAccent boolean true
stopWord Object null
unorderedDocument boolean true

Case sensitive

const client = new Search({
    caseSensitive: true
});

client.index('001', 'The Lord of the Rings');
client.index('002', 'The Hobbit');

client.search('hobbit'); // []
client.search('Hobbit'); // ["002"]

Exact word strategy

const client = new Search({
    exactWordStrategy: true
});

client.index('001', 'The Lord of the Rings');
client.index('002', 'The Hobbit');

client.search('o'); // []
client.search('Rings'); // ["001"]

Ignore accent

const client = new Search({
    ignoreAccent: false
});

client.index('001', 'Parásitos');
client.index('002', 'Déjame salir');
client.index('003', 'El Tiburón');

client.search('Tiburon'); // []
client.search('Tiburón'); // ["003"]

Stop word

const client = new Search({
    stopWord: {
        the: true
    }
});

client.index('001', 'The Lord of the Rings');
client.index('002', 'The Hobbit');

client.search('the'); // []
client.search('the hobbit'); // ["002"]

Unordered document

const client = new Search({
    unorderedDocument: false
});

client.index('001', 'The Lord of the Rings');
client.index('002', 'The Hobbit');

client.search('the'); // ["001", "002"]
client.search('the hobbit'); // ["002", "001"]

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i monolieta-search

Weekly Downloads

163

Version

1.2.3

License

MIT

Unpacked Size

19.1 kB

Total Files

20

Last publish

Collaborators

  • jonattan