searchico

1.2.1 • Public • Published

Searchico

Build Status npm version GitHub license Open Source Love

A very fast full-text search in JavaScript

Install

From NPM

npm install searchico

From GitHub

npm install git+https://github.com/illusion1993/searchico.git

Documentation

Init

var searchico = require('searchico');
var collection = searchico([
    { id: 1, name: 'Alex Carter', location: 'New Orleans' },
    { id: 2, name: 'Alexey Hopper', location: 'Lake Charles' },
    { id: 3, name: 'Jack Tyson', location: 'New Orleans' },
    { id: 4, name: 'Tyler Miles', location: 'Camas' }
]);
var results1 = collection.find('alex');
var results2 = collection.find('orlea');
 
/* 
results1 = [
    { id: 1, name: 'Alex Carter', location: 'New Orleans' },
    { id: 2, name: 'Alexey Hopper', location: 'Lake Charles' }
results2 = [
    { id: 1, name: 'Alex Carter', location: 'New Orleans' },
    { id: 3, name: 'Jack Tyson', location: 'New Orleans' }
*/

Options

var searchico = require('searchico');
var options = {
    case_sensitive: true,   // false by default
    hyper_indexing: true,   // true by default, high speed search, memory intensive
    hyper_caching: true,    // false by default, even faster, memory intensive
    replace_umlauts: true,  // true by default, allows finding umlauts with their english alphabets
    deep: false,            // true by default, allows indexing objects deeply
    keys: ['id', 'name']    // name of keys in objects to add into index
};
var data = [
    { id: 1, name: 'Alex Carter', location: 'New Orleans' },
    { id: 2, name: 'Alexey Hopper', location: 'Lake Charles' },
    { id: 3, name: 'Jack Tyson', location: 'New Orleans' },
    { id: 4, name: 'Tyler Miles', location: 'Camas' }
];
var collection = searchico(data, options);
var results = collection.find('Ty');

Usages

  • Object arrays
     var data = [{ id:2, name: 'Apple' }, { id: 14, name: 'Orange' }];
     var collection = searchico(data);
  • String Arrays
    var data = ['Apple', 'Orange', 'Guava'];
    var collection = searchico(data);
  • Mixed Arrays
    var data = ['Apple', { id: 14, name: 'Orange' }, 'Guava'];
    var collection = searchico(data);

License

MIT © Vikram Singh Rathore

Package Sidebar

Install

npm i searchico

Weekly Downloads

85

Version

1.2.1

License

MIT

Last publish

Collaborators

  • illusion1993