Fix Cluster combining avg() as an unweighted mean of shard averages (#1237)

This commit is contained in:
Amir Fathi
2026-09-14 10:18:52 -04:00
committed by GitHub
parent ebe13ae304
commit 72f9ca7605
3 changed files with 56 additions and 4 deletions
+2 -1
View File
@@ -241,7 +241,8 @@ class TestCluster(unittest.TestCase):
query = urllib.parse.quote("select count(*), min(indexid), max(indexid), avg(indexid) from txtai where text='This is a test'")
self.assertEqual(
self.client.get(f"search?query={query}").json(), [{"count(*)": 28, "min(indexid)": 0, "max(indexid)": 14, "avg(indexid)": 6.5}]
self.client.get(f"search?query={query}").json(),
[{"count(*)": 28, "min(indexid)": 0, "max(indexid)": 14, "avg(indexid)": 182.8 / 28}],
)
query = urllib.parse.quote("select count(*), text txt from txtai group by txt order by count(*) desc")