How to apply multiple query parameters with redis-om (for python)

277 views Asked by At

A classic. One wants to submit multiple optional search/filter criteria. e.g. "Return all only cats" would result in Animals.find(Animals.type == "cat").all(). Great, but what if one wants to optionally filter by age. One needs another if-statement with another query string combination. Hence, one ends up with a combination of all optional search criteria. I think it is more elegant to compose the complete search criteria. As shown in this redis search example. How would we elegently solve this in redis-om ?

There are examples, but they don't cover the case of composing multiple optional search criteria. https://github.com/redis/redis-om-python/blob/main/docs/fastapi_integration.md

1

There are 1 answers

0
Lukelu On

It seems RedisOM-Python is not ready to support creating dynamic query conditions.

Since RedisOM uses RediSearch as search engine, I'll use redisearch to do data filtering directly.

Good luck!