redisearch
A plugin to search data with redis
Last updated 2 years ago .
· Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install redisearch 
SYNC missed versions from official npm registry.

redis-search

Index and search data in redis

Inspired by https://github.com/tj/reds

Differences :

query on extra fields

How to use :

var redisSearch = require('redisSearch');

var postSearch = redisSearch.createSearch('mypostsearch', [redisClient]);

Indexing:

postSearch.index(data, id, callback);

// index some stuff, the string field must be named `content` others can be anything
postSearch.index({content: 'ruby emerald', uid: 5, cid: 1}, 1, next);
postSearch.index({content: 'emerald orange emerald', uid: 5, cid: 2}, 2, next);
postSearch.index({content: 'cucumber apple orange', uid: 4, cid: 2}, 3, next);
postSearch.index({content: 'orange apple pear', uid: 5, cid: 4}, 4, next);
postSearch.index({content: 'dog cat', uid: 6, cid: 4}, 5, next);

Search

postSearch.query(data, callback);

postSearch.query({content: "orange", uid: 5, cid: 2}, function(err, ids) {
    console.log(ids); // ["2"]
});

Remove from index:

postSearch.remove(id);

postSearch.remove(3);

Other examples:

// search for ids where content contains `orange` and cid is 2 or 4
postSearch.query({content: "orange", cid: [2,4]}, callback);

// search for ids where uid is 5 and return 3 results
postSearch.query({uid: 5}, 0, 2);

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

10 Versions

  • 0.0.3                                ...           8 years ago
  • 0.0.4                                ...           8 years ago
  • 0.0.5                                ...           7 years ago
  • 0.0.6                                ...           7 years ago
  • 0.0.7                                ...           5 years ago
  • 0.0.9                                ...           5 years ago
  • 0.0.10                                ...           4 years ago
  • 0.0.11                                ...           4 years ago
  • 0.0.8                                ...           5 years ago
  • 1.0.0                                ...           2 years ago
Maintainers (1)
Dependencies (2)
Dev Dependencies (1)

Copyright © npmmirror.com | 浙ICP备15033595号-63 |