From 0f7ae937dff263eeb2615dea7332026dfb20e86b Mon Sep 17 00:00:00 2001 From: Simon Prickett Date: Mon, 25 Apr 2022 10:58:24 +0100 Subject: [PATCH] Updates topk example for new withcount option. (#2093) --- examples/topk.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/examples/topk.js b/examples/topk.js index 1412972434..024dc30ecb 100644 --- a/examples/topk.js +++ b/examples/topk.js @@ -66,6 +66,24 @@ async function topK() { // ] console.log(top10); + // List out the top 10 with their counts (requires RedisBloom >=2.2.9) + const top10WithCounts = await client.topK.listWithCount('mytopk'); + console.log('The top 10 with counts:'); + console.log(top10WithCounts); + // top10WithCounts looks like this: + // [ + // { item: 'suze', count: 42363 }, + // { item: 'lance', count: 41982 }, + // { item: 'simon', count: 41831 }, + // { item: 'steve', count: 39237 }, + // { item: 'guy', count: 39078 }, + // { item: 'kyleb', count: 37338 }, + // { item: 'leibale', count: 34230 }, + // { item: 'kyleo', count: 33812 }, + // { item: 'alex', count: 33679 }, + // { item: 'nava', count: 32663 } + // ] + // Check if a few team members are in the top 10 with TOPK.QUERY: const [ steve, suze, leibale, frederick ] = await client.topK.query('mytopk', [ 'steve',