searchico

A very fast full-text search in JavaScript

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
searchico
641.2.16 years ago7 years agoMinified + gzip package size for searchico in KB

Readme

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
```js
 var data = [{ id:2, name: 'Apple' }, { id: 14, name: 'Orange' }];
 var collection = searchico(data);
```
- String Arrays
```js
var data = ['Apple', 'Orange', 'Guava'];
var collection = searchico(data);
```
- Mixed Arrays
```js
var data = ['Apple', { id: 14, name: 'Orange' }, 'Guava'];
var collection = searchico(data);
```

License

MITlicense © Vikram Singh Rathoreauthor