Solution
For this process you typically need to use the Redis TS.MRANGE command, which stands for "TimeSeries Multi-Range." With the help of this command you can perform aggregation operations on one or more time series in Redis. Install RedisTimeSeries module and load in your Redis server before using aggregation.
The following code you can use to aggregate data and receive the result:
const result = await redisClient.ft.aggregate(indexName, queryPattern, { STEPS: [{ type: AggregateSteps.FILTER, expression: `${userList.map(username => `@username=='${username}'`).join(' || ')}`, }, { type: AggregateSteps.GROUPBY, properties: ['@pids'], REDUCE: [{ type: AggregateGroupByReducers.TOLIST, property: '@username', AS: 'users', }], }], }) logger.info('Got result\nSize: ', JSON.stringify(result.total)) logger.debug('\nData: ' + JSON.stringify(result.results)) } catch (error) { logger.error('Error:', error) } |
Answered by: >tuxian
Credit: >StackOverflow
Suggested Blogs
>Creating a pivot table by 6 month interval rather than year
>How remove residual lines after merge two regions using Geopandas in python?
>How to mock a constant value in Python?
>Can I call an API to find out the random seed in Python `hash()` function?
>How to configure python in jmeter?
>How to fix routes in Laravel?