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
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?
//edit:
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);
newsArticleRepository.createIndex();
return newsArticleRepository;
});
If it helps, the type of the index is STRING, while the type of the indexed object is JSON.
2
Answers
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.
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.