Is it possible to send arbitrary commands to Redis using ioredis for Node JS?
For example, I'm using the new RediSearch module, and want to create an index using the command:
FT.CREATE test SCHEMA title TEXT WEIGHT 5.0
How would I send this command using ioredis?
This will get you there, although not sure about the response encoding:
var
Redis = require('ioredis'),
redis = new Redis('redis://:[yourpassword]@127.0.0.1');
redis.sendCommand(
new Redis.Command(
'FT.CREATE',
['test','SCHEMA','title','TEXT','WEIGHT','5.0'],
'utf-8',
function(err,value) {
if (err) throw err;
console.log(value.toString()); //-> 'OK'
}
)
);
If you're willing to search to node_redis, there is a pre-built RediSearch plugin that supports all the RediSearch commands. (Disclosure: I wrote it)