Skip to content

Commit 0f7ae93

Browse files
author
Simon Prickett
authored
Updates topk example for new withcount option. (#2093)
1 parent 448ac9d commit 0f7ae93

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

examples/topk.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,24 @@ async function topK() {
6666
// ]
6767
console.log(top10);
6868

69+
// List out the top 10 with their counts (requires RedisBloom >=2.2.9)
70+
const top10WithCounts = await client.topK.listWithCount('mytopk');
71+
console.log('The top 10 with counts:');
72+
console.log(top10WithCounts);
73+
// top10WithCounts looks like this:
74+
// [
75+
// { item: 'suze', count: 42363 },
76+
// { item: 'lance', count: 41982 },
77+
// { item: 'simon', count: 41831 },
78+
// { item: 'steve', count: 39237 },
79+
// { item: 'guy', count: 39078 },
80+
// { item: 'kyleb', count: 37338 },
81+
// { item: 'leibale', count: 34230 },
82+
// { item: 'kyleo', count: 33812 },
83+
// { item: 'alex', count: 33679 },
84+
// { item: 'nava', count: 32663 }
85+
// ]
86+
6987
// Check if a few team members are in the top 10 with TOPK.QUERY:
7088
const [ steve, suze, leibale, frederick ] = await client.topK.query('mytopk', [
7189
'steve',

0 commit comments

Comments
 (0)