Socket
Socket
Sign inDemoInstall

@redis/search

Package Overview
Dependencies
Maintainers
1
Versions
11
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


Version published
Weekly downloads
2.2M
increased by6.98%
Maintainers
1
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

FAQs

Package last updated on 22 Aug 2022

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