Search library for browser and Node.js
Install monolieta-search
using yarn or npm
yarn add monolieta-search
npm install monolieta-search
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"]
Name | Type | Default |
---|---|---|
caseSensitive | boolean | false |
exactWordStrategy | boolean | false |
ignoreAccent | boolean | true |
stopWord | Object | null |
unorderedDocument | boolean | true |
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"]
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"]
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"]
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"]
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"]
This project is licensed under the MIT License.