redis / redis-om-node

Object mapping, and more, for Redis and Node.js. Written in TypeScript.
MIT License
1.18k stars 80 forks source link

How To: execute complex searches #224

Open MR4online opened 10 months ago

MR4online commented 10 months ago

Hi there,

is there a way to execute some more complex search queries?

Examples:

1) FIND album WHERE year = 1990 OR year IS NULL (or undefined) [EDIT: this will not work at all (redis search limitation)]

2) FIND album WHERE (year = 1990 OR year = 2000) AND foo = "bar 3) FIND album WHERE year = 1990 OR (year = 2000 AND foo = "bar)

In the given examples I don't see if this is possible, or I'm not sure how RedisOM handles multiple AND & OR associations. Or is there at least a way to print the generated search-query?

[EDIT: one can log the search query:

const search = albumRepository.search().where('year').eq(1984);
console.log(search.query);
await search.return.all();

]

Thank you!

SylvainAssemat commented 7 months ago

Hi

Maybe could you look at the "filter" method using Predicate in EntityStream ? With this you could chain AND / OR condition in order to get what you expect.

JohnLopen commented 2 months ago

Hi

Maybe could you look at the "filter" method using Predicate in EntityStream ? With this you could chain AND / OR condition in order to get what you expect.

Hi, I'm applying your suggestion to my solution, but I'm curious how long can the chain go? Because when I try chaining more than 10 search terms it failed

SylvainAssemat commented 2 months ago

I have already use more than 10 chain without any problem (multiple OR for geoqueries tiles)

Can you post a snippet maybe ?

JohnLopen commented 2 months ago

I have already use more than 10 chain without any problem (multiple OR for geoqueries tiles)

Can you post a snippet maybe ?

Thank you for your quick response. I have posted an issue here, and detailed everything, will this help?