Code Monkey home page Code Monkey logo

monolieta-search's Introduction

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.

monolieta-search's People

Contributors

jonattanva avatar dependabot[bot] avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.