skip to Main Content

I have an instance of Redis containing JSON objects.

Example of JSON object:

  description: ""
  metaPublishedOnDiscord: true
  metaIsHot: false

I have also an index for these objects called NewsArticles:index.

From redis insights, I want to find all JSON objects containing metaPublishedOnDiscord: false

enter image description here

From in the attached image I am trying to find all objects that have the boolean metaPublishedOnDiscord set to true. @metaPublishedOnDiscord:true on NewsArticle:index doesn’t work. What is the correct syntax?

I created the index using legacy redis-om api.

const Connection = require('./Connection');
const { Schema, Entity } = require('redis-om');

class NewsArticle extends Entity {};

const newsArticleSchema = new Schema(NewsArticle, {
    url: { type: 'string' }, 
    img: { type: 'string' }, 
    title: { type: 'text' },
    description: { type: 'text' },
    content: { type: 'text' },
    tags: { type: 'string[]' },
    cityId: { type: 'string' },
    metaScrapedAtTimestamp: { type: 'date' },
    metaPublishedOnDiscord: { type: 'boolean' },
    metaIsHot: { type: 'boolean' }

module.exports = Connection.start().then(c => {
    const newsArticleRepository = c.fetchRepository(newsArticleSchema);
    return newsArticleRepository;

If it helps, the type of the index is STRING, while the type of the indexed object is JSON.

enter image description here



  1. Chosen as BEST ANSWER

    I've found an answer. The correct way is to use this kind of syntax:


    My problem is that i have been missing {} wrapping the value.

  2. En Redis Insights, puedes filtrar objetos JSON por valor de clave utilizando la sintaxis adecuada de Redis commands. Por ejemplo, si quieres filtrar objetos JSON por el valor de una clave especĂ­fica, puedes usar el comando JSON.GET junto con el filtro adecuado.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top