redis-index

4.1.0 • Public • Published

redis-index

Build Status

Index and query arbitrary objects with Redis.

example

var index = require('redis-index').createIndex('item', 'item_id');
 
index.add({ item_id : 1, name : "thing a", type : 100 });
index.add({ item_id : 2, name : "thing b", type : 100 });
index.add({ item_id : 3, name : "thing c", type : 200 });
 
setTimeout(function () {
    index.search({ name : 'b' }).or({ item_id : 1 }).exec(function (err, result) {
        /*
            [ { item_id : 1, name : "thing a", type : 100 },
            { item_id : 2, name : "thing b", type : 100 } ]
        */
    });
}, 1000);

api

RedisIndex

  • RedisIndex.createIndex(options)

Create a new index to which objects may be added.

  • options : options objects
    • key : string - the namespace key to use when storing keys in redis
    • index : string - the attribute which exists on an object being indexed which should be used to uniquely identify that object.
    • schemaOnly : boolean - when true, only index fields identified in the schema
    • fullText : function - when exists, this function will be called with each object being added to the index. The function should return a string to be indexed for full text search. This option must be present in order to enable full text search.
    • schema : object - an object which identifies information about attributes encountered when indexing.
    • compress : object - and object with synchronous encode and decode functions for compressing and decompressing values

more examples

compression

var RedisIndex = require('redis-index');
 
var index = RedisIndex.createIndex({
    key : 'item'
    , index : 'item_id'
    , compress : RedisIndex.compression.gzip
});
 

TODO

  • proper tests
  • comparisons
  • deep lookups
  • arrays of values
  • arrays of objects
  • automatic full deep indexing
  • wildcards for schema definitions
  • add comparisons
    • exists
    • empty/notExists
    • contains
    • begins with
    • ends with
    • in array (of values)
  • full text
  • string comparisons
  • sorting
  • intersect with other indexes
  • store key
  • add array of objects
  • custom string tokenizing
  • paging
  • make Promise compatible
  • compression

license

MIT

Dependencies (6)

Dev Dependencies (2)

Package Sidebar

Install

npm i redis-index

Weekly Downloads

29

Version

4.1.0

License

MIT

Unpacked Size

68.3 kB

Total Files

34

Last publish

Collaborators

  • wankdanker