{"id":46203,"library":"reds","title":"reds","description":"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.","status":"maintenance","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/visionmedia/reds","tags":["javascript","redis","search","metaphone","phonetics","natural"],"install":[{"cmd":"npm install reds","lang":"bash","label":"npm"},{"cmd":"yarn add reds","lang":"bash","label":"yarn"},{"cmd":"pnpm add reds","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for Redis client operations; reds relies on a node_redis instance.","package":"redis","optional":false},{"reason":"Provides stemming and metaphone phonetic algorithms for text processing.","package":"natural","optional":false}],"imports":[{"note":"ESM default import works; reds is a CommonJS module but many bundlers support default import.","wrong":"const reds = require('reds');","symbol":"reds","correct":"import reds from 'reds';"},{"note":"Named export for createSearch; can be used in both ESM and CJS contexts.","wrong":"const { createSearch } = require('reds');","symbol":"createSearch","correct":"import { createSearch } from 'reds';"},{"note":"Named export for the Search class; direct access to the constructor.","wrong":"const Search = require('reds').Search;","symbol":"Search","correct":"import { Search } from 'reds';"},{"note":"Named export to set a custom Redis client instance.","wrong":"const setClient = require('reds').setClient;","symbol":"setClient","correct":"import { setClient } from 'reds';"}],"quickstart":{"code":"import reds from 'reds';\nimport redis from 'redis';\n\nconst client = redis.createClient({ url: process.env.REDIS_URL || 'redis://localhost:6379' });\nreds.setClient(client);\n\nconst search = reds.createSearch('pets');\n\nconst strs = [];\nstrs.push('Tobi wants four dollars');\nstrs.push('Tobi only wants $4');\nstrs.push('Loki is really fat');\nstrs.push('Loki, Jane, and Tobi are ferrets');\nstrs.push('Manny is a cat');\nstrs.push('Luna is a cat');\nstrs.push('Mustachio is a cat');\n\n// Index documents\nstrs.forEach((str, i) => {\n  search.index(str, i);\n});\n\n// Query with intersection (default)\nsearch\n  .query('Tobi dollars')\n  .end((err, ids) => {\n    if (err) throw err;\n    console.log('Search results for \"Tobi dollars\":');\n    ids.forEach(id => console.log('  -', strs[id]));\n  });\n\n// Query with union\nsearch\n  .query('tobi dollars')\n  .type('or')\n  .end((err, ids) => {\n    if (err) throw err;\n    console.log('Search results for \"tobi dollars\" (union):');\n    ids.forEach(id => console.log('  -', strs[id]));\n  });","lang":"typescript","description":"Shows full setup: Redis client creation, indexing multiple documents, and querying with both intersection (default) and union modes."},"warnings":[{"fix":"Re-index all documents after upgrading to 1.0.0.","message":"Version 1.0.0 requires re-indexing of documents indexed with older versions (0.2.x) due to natural module upgrade.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Be aware of phonetic limitations; test queries with your data.","message":"Search results are based on phonetic matching (metaphone), so queries may return unexpected results for homophones.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Wrap calls in try-catch or handle errors in callbacks.","message":"The library uses Redis sets; ensure Redis is running and accessible. No built-in error handling for connection failures.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Always use 'or' or 'union' explicitly.","message":"The 'type' method expects strings 'or' or 'union' (case-insensitive). Passing other values may silently fall back to default.","severity":"deprecated","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'1.0.0':16,69 'capabl':33 'current':13 'default':63 'design':39 'document':75 'due':80 'easili':54 'engin':49 'exist':56 'full':30,47 'full-text':29 'index':73,76 'infrequ':94 'integr':53 'intersect':62 'javascript':96 'librari':10,86 'light':6 'light-weight':5 'mainten':91 'match':20 'metaphon':25,99 'mode':67,92 'modul':24,83 'natur':23,82,101 'node.js':12 'older':78 'overkil':51 'phonet':19,100 'project':44 'provid':27 'queri':66 're':72 're-index':71 'red':1,2,37 'redi':8,35,57,97 'requir':70 'scale':43 'search':9,32,48,98 'set':36 'setup':58 'simpl':28 'small':42 'small-scal':41 'stabl':88 'support':60 'text':31 'union':65 'updat':95 'upgrad':84 'use':18 'version':15,68,79 'via':21 'weight':7","created_at":"2026-06-07T12:58:46.753772+00:00","updated_at":"2026-06-07T12:58:46.753772+00:00","problems":[{"fix":"Use correct import: import reds from 'reds'; or const reds = require('reds').default;","cause":"Using require() on ESM import or mismatched import style.","error":"TypeError: reds.createSearch is not a function"},{"fix":"Start Redis server or set REDIS_URL environment variable to a valid Redis instance.","cause":"Redis server is not running or connection parameters are wrong.","error":"Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED"},{"fix":"Chain correctly: search.query('text').end(callback); OR search.query('text').type('or').end(callback);","cause":"Forgetting to call .query() returns a Query object; .type() and .end() are methods on that object.","error":"TypeError: search.query(...).end is not a function"},{"fix":"Run npm install natural (should be automatically installed with reds, but if missing, install explicitly).","cause":"natural dependency not installed.","error":"Error: Cannot find module 'natural'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/visionmedia/reds#readme","github":"https://github.com/visionmedia/reds","docs":null,"changelog":null,"pypi":null,"npm":"reds","openapi_spec":null,"status_page":null,"smithery":null,"categories":["search"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}