redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.12k stars 112 forks source link

enhancement: find().count() #313

Open tomcounsell opened 2 years ago

tomcounsell commented 2 years ago

.find().count() will return a count of the number of matching records for a query. This returns only the number of results without needing to collect the records. solves #283

tomcounsell commented 2 years ago

first attempt at a PR here! please review and propose changes to match code style and tests.

There was not an obvious way to implement this much needed feature. Using the AGGREGATE GROUP BY REDUCE feature may not be the best choice. Would love to find a better alternative.

Currently, this implementation is not working for queries where multiple find parameters match the same record. It will count duplicate matches twice. So the current implementation works only for queries with single parameters and the base find().count() use case.