Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

redis-om

БесплатноБез исполняемых скриптовНе проверен

Redis OM maps JavaScript or Python objects to Redis JSON documents or hashes and builds RediSearch indexes from the schema, so you can save, fetch and search…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

Redis OM

Overview

Redis OM is an object mapper for Redis. You define a schema (Node.js) or a model class (Python), save plain objects as RedisJSON documents or hashes, and query them through a fluent API that compiles to RediSearch (FT.SEARCH). It needs a server with the JSON and Search modules: Redis Stack or Redis Cloud (see the Redis 8 pitfall for Node below). A plain Redis server without those modules cannot run searches.

Versions checked on 2026-10-24: redis-om (npm) 0.4.7, redis-om (PyPI) 1.2.0.

Instructions

Node.js / TypeScript

npm install redis-om redis@4
docker run -d --name redis-stack -p 127.0.0.1:6379:6379 redis/redis-stack-server:7.4.0-v8

redis-om 0.4.7 depends on node-redis 4. Install redis@4 yourself: a bare npm install redis now brings v6, and passing that client to a Repository is not the version redis-om was built for.

There is no Client class in 0.4: you create a node-redis client and give it to the Repository.

import { createClient } from "redis";
import { Schema, Repository, EntityId } from "redis-om";

const redis = createClient({ url: process.env.REDIS_URL ?? "redis://127.0.0.1:6379" });
redis.on("error", (err) => console.error("Redis error", err));
await redis.connect();

const productSchema = new Schema("product", {
  name: { type: "string" },                    // exact match / wildcard
  description: { type: "text" },               // full-text search
  price: { type: "number", sortable: true },
  category: { type: "string[]" },              // tags
  inStock: { type: "boolean" },
  createdAt: { type: "date", sortable: true },
  location: { type: "point" },                 // { longitude, latitude }
});

const products = new Repository(productSchema, redis);
await products.createIndex();                  // safe on every start; rebuilds only if the schema changed

const keyboard = await products.save({
  name: "Wireless Keyboard",
  description: "Ergonomic bluetooth keyboard with backlight and long battery life",
  price: 79.99,
  category: ["electronics", "peripherals"],
  inStock: true,
  createdAt: new Date(),
  location: { longitude: -122.4194, latitude: 37.7749 },
});
const id = keyboard[EntityId];                 // generated ULID, stored under a Symbol
const same = await products.fetch(id);

Schema types are string, text, number, boolean, date, point, string[], number[]. Data defaults to JSON; pass { dataStructure: "HASH" } as the third argument for hashes (flat, no number[]).

Queries (all verified against Redis Stack 7.4):

const hits = await products.search()
  .where("description").matches("ergonomic bluetooth")
  .and("inStock").is.true()
  .and("price").is.between(50, 150)
  .sortBy("price", "ASC")
  .page(0, 20);                                // offset, count

const tagged = await products.search().where("category").contains("electronics").return.all();
const nearby = await products.search()
  .where("location").inRadius((c) => c.origin(-122.4194, 37.7749).radius(10).miles)
  .return.all();
const total = await products.search().where("inStock").true().return.count();

Other repository methods: save(customId, entity), remove(id), expire(id, seconds), dropIndex(), search().return.first().

Python

pip install redis-om

In 1.x a model must be declared with index=True, otherwise save() raises RedisModelError: You cannot create a key on a model that is not indexed.

import os
from redis_om import JsonModel, Field, Migrator, get_redis_connection

redis = get_redis_connection(url=os.environ.get("REDIS_URL", "redis://127.0.0.1:6379"))

class Product(JsonModel, index=True):
    name: str = Field(index=True)
    description: str = Field(index=True, full_text_search=True)
    price: float = Field(index=True, sortable=True)
    category: str = Field(index=True)
    in_stock: bool = Field(index=True, default=True)

    class Meta:
        database = redis

Migrator().run()                               # creates or updates the indexes

mouse = Product(name="Wireless Mouse", description="Ergonomic wireless mouse",
                price=49.99, category="electronics")
mouse.save()                                   # mouse.pk is the generated ULID

cheap = Product.find(
    (Product.category == "electronics") & (Product.price < 100) & (Product.in_stock == True)
).sort_by("price").all()
ergonomic = Product.find(Product.description % "ergonomic").all()   # full-text
same = Product.get(mouse.pk)

Use HashModel instead of JsonModel for hash storage; the same code works (checked). The package also exports VectorFieldOptions for vector fields in Python models.

Examples

Example 1: Product catalog search API

User request: "Store my product catalog in Redis and let the storefront search by words in the description, a price range and in-stock only."

Actions: install redis-om and redis@4, define the product schem

Полный SKILL.md на GitHub

Установить redis-om в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл redis-om?

Redis OM maps JavaScript or Python objects to Redis JSON documents or hashes and builds RediSearch indexes from the schema, so you can save, fetch and search entities without raw Redis commands. Use when you need to model data in Redis as a primary database, add full-text, tag, numeric or geo search to Redis data, or set up redis-om in Node.js (TypeScript) or Python (FastAPI, Pydantic).

Как установить скилл redis-om?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл redis-om запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить redis-om с