Index and query arbitrary JavaScript objects using Redis. Version 4.1.0 provides a simple API to index objects by fields and perform search queries with OR conditions, full-text search, sorting, paging, and compression. It supports callbacks and Promises, and offers schema-based indexing. Compared to RediSearch, redis-index is a lightweight library that works with standard Redis (no modules needed), but lacks advanced query features like aggregation and ranked search. Active maintenance on GitHub with regular releases.
npm install redis-indexNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Create a RedisIndex, add objects with a unique identifier, search with OR conditions, and retrieve results.
Use async/await or .then() instead of callbacks. For example: await index.add(obj); instead of index.add(obj, callback);
Create a Redis client (e.g., from 'redis' package) and pass it as: createIndex({ redis: client, ... })Replace new RedisIndex({...}) with createIndex({...})Ensure encode and decode are synchronous and handle errors internally.
Use a unique key (like a database primary key) for the index field.
Use import { createIndex } from 'redis-index'; or const { createIndex } = require('redis-index');Use require('redis-index').createIndex or destructure.Use redis-index's search() method instead of raw Redis commands.
Provide a function that returns a string for full-text indexing.