Registry / search / reds
library1.0.0jsnpmunverified

Reds is a light-weight Redis search library for Node.js, currently at version 1.0.0. It uses phonetic matching via the natural module (metaphone) to provide simple full-text search capabilities over Redis sets. Reds is designed for small-scale projects where a full search engine is overkill, and integrates easily with existing Redis setups. It supports both intersection (default) and union query modes. Version 1.0.0 requires re-indexing of documents indexed with older versions due to natural module upgrades. The library is stable but in maintenance mode with infrequent updates.

npm install reds
INSTALL
IMPORT
SIG · REDS
R
reds
searchjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

reds
import reds from 'reds';
const reds = require('reds');
ESM default import works; reds is a CommonJS module but many bundlers support default import.
createSearch
import { createSearch } from 'reds';
const { createSearch } = require('reds');
Named export for createSearch; can be used in both ESM and CJS contexts.
Search
import { Search } from 'reds';
const Search = require('reds').Search;
Named export for the Search class; direct access to the constructor.
setClient
import { setClient } from 'reds';
const setClient = require('reds').setClient;
Named export to set a custom Redis client instance.

Shows full setup: Redis client creation, indexing multiple documents, and querying with both intersection (default) and union modes.

import reds from 'reds'; import redis from 'redis'; const client = redis.createClient({ url: process.env.REDIS_URL || 'redis://localhost:6379' }); reds.setClient(client); const search = reds.createSearch('pets'); const strs = []; strs.push('Tobi wants four dollars'); strs.push('Tobi only wants $4'); strs.push('Loki is really fat'); strs.push('Loki, Jane, and Tobi are ferrets'); strs.push('Manny is a cat'); strs.push('Luna is a cat'); strs.push('Mustachio is a cat'); // Index documents strs.forEach((str, i) => { search.index(str, i); }); // Query with intersection (default) search .query('Tobi dollars') .end((err, ids) => { if (err) throw err; console.log('Search results for "Tobi dollars":'); ids.forEach(id => console.log(' -', strs[id])); }); // Query with union search .query('tobi dollars') .type('or') .end((err, ids) => { if (err) throw err; console.log('Search results for "tobi dollars" (union):'); ids.forEach(id => console.log(' -', strs[id])); });
Debug
Known issues
breakingVersion 1.0.0 requires re-indexing of documents indexed with older versions (0.2.x) due to natural module upgrade.
fix
Re-index all documents after upgrading to 1.0.0.
affects: <1.0.0
gotchaSearch results are based on phonetic matching (metaphone), so queries may return unexpected results for homophones.
fix
Be aware of phonetic limitations; test queries with your data.
affects: >=0.0.0
gotchaThe library uses Redis sets; ensure Redis is running and accessible. No built-in error handling for connection failures.
fix
Wrap calls in try-catch or handle errors in callbacks.
affects: >=0.0.0
deprecatedThe 'type' method expects strings 'or' or 'union' (case-insensitive). Passing other values may silently fall back to default.
fix
Always use 'or' or 'union' explicitly.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: reds.createSearch is not a function
Using require() on ESM import or mismatched import style.
fix
Use correct import: import reds from 'reds'; or const reds = require('reds').default;
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
Redis server is not running or connection parameters are wrong.
fix
Start Redis server or set REDIS_URL environment variable to a valid Redis instance.
TypeError: search.query(...).end is not a function
Forgetting to call .query() returns a Query object; .type() and .end() are methods on that object.
fix
Chain correctly: search.query('text').end(callback); OR search.query('text').type('or').end(callback);
Error: Cannot find module 'natural'
natural dependency not installed.
fix
Run npm install natural (should be automatically installed with reds, but if missing, install explicitly).
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
redisrequiredRequired for Redis client operations; reds relies on a node_redis instance.
naturalrequiredProvides stemming and metaphone phonetic algorithms for text processing.
Agent activity
33 hits · last 30 days
node
30
Resources
packagereds