Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@redis/search

Package Overview
Dependencies
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@redis/search

This package provides support for the [RediSearch](https://redisearch.io) module, which adds indexing and querying support for data stored in Redis Hashes or as JSON documents with the RedisJSON module. It extends the [Node Redis client](https://github.c

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7M
decreased by-25.93%
Maintainers
3
Weekly downloads
 
Created

What is @redis/search?

The @redis/search npm package is designed to facilitate full-text search capabilities in Redis. It leverages the RediSearch module to provide powerful search functionalities, including indexing, querying, and full-text search within Redis databases. This package allows developers to efficiently implement search features in their applications by using Redis as the underlying technology.

What are @redis/search's main functionalities?

Creating an Index

This feature allows you to create an index on your Redis data. The example demonstrates creating an index named 'idx:movie' on a JSON document, specifying fields like title, description, and genre with their respective data types.

const { Client } = require('@redis/client');
const { createClient } = require('@redis/search');

async function main() {
  const client = createClient();
  await client.ft.create('idx:movie', {
    '$.title': 'TEXT',
    '$.description': 'TEXT',
    '$.genre': 'TAG'
  }, {
    ON: 'JSON'
  });
}

main();

Searching an Index

This feature enables searching through the index you've created. The code sample searches the 'idx:movie' index for movies with the title 'Inception' and logs the results.

const { Client } = require('@redis/client');
const { createClient } = require('@redis/search');

async function main() {
  const client = createClient();
  const results = await client.ft.search('idx:movie', '@title:(Inception)');
  console.log(results);
}

main();

Aggregating Search Results

This feature allows for the aggregation of search results based on certain criteria. In this example, it aggregates movies by genre, specifically 'Action', and counts how many movies fall into this category.

const { Client } = require('@redis/client');
const { createClient } = require('@redis/search');

async function main() {
  const client = createClient();
  const results = await client.ft.aggregate('idx:movie', '@genre:{Action}', {
    LOAD: ['$.title'],
    GROUPBY: ['@genre'],
    REDUCE: ['COUNT', 0, 'AS', 'count']
  });
  console.log(results);
}

main();

Other packages similar to @redis/search

Keywords

FAQs

Package last updated on 29 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc