We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ee3fd30 commit ea171a8Copy full SHA for ea171a8
aredis_om/model/model.py
@@ -760,6 +760,25 @@ async def all(self, batch_size=10):
760
return await query.execute()
761
return await self.execute()
762
763
+ async def count(self):
764
+ args = ["FT.AGGREGATE", self.model.Meta.index_name, "*"]
765
+ if self.expression:
766
+ args += ["FILTER", *self.query]
767
+ args += [
768
+ "APPLY",
769
+ "matched_terms()",
770
+ "AS",
771
+ "countable",
772
+ "GROUPBY",
773
+ "1",
774
+ "@countable",
775
+ "REDUCE",
776
+ "COUNT",
777
+ "0",
778
+ ]
779
+ raw_result = await self.model.db().execute_command(*args)
780
+ return sum([count for [count, _] in raw_result])
781
+
782
def sort_by(self, *fields: str):
783
if not fields:
784
return self
0 commit comments