Skip to content

Commit f2c14f4

Browse files
author
Simon Prickett
committed
Fixed sorting on FT.AGGREGATE.
1 parent 36c0fd6 commit f2c14f4

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

sample-app/redisearch-node-rest/NodeSearchService.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,11 @@ const SearchService = function () {
6363
raw: [] // Used to return the raw response from Node Redis.
6464
};
6565

66-
// TODO Remove this...
67-
const pipeline = [
68-
indexNameMovies, // name of the index
69-
'*', // query string,
70-
'GROUPBY', '1', `@${field}`, // group by
71-
'REDUCE', 'COUNT', '0', 'AS', 'nb_of_movies', //count the number of movies by group
72-
'SORTBY', '2', `@${field}`, 'ASC', // sorted by the genre
73-
'LIMIT', '0', '1000' // get all genre expecting less than 100 genres
74-
];
75-
7666
const aggrResult = await client.ft.aggregate(indexNameMovies, '*', {
7767
STEPS: [
7868
{
7969
type: AggregateSteps.GROUPBY,
80-
properties: field,
70+
properties: `@${field}`,
8171
REDUCE: [
8272
{
8373
type: 'COUNT',
@@ -87,8 +77,10 @@ const SearchService = function () {
8777
},
8878
{
8979
type: AggregateSteps.SORTBY,
90-
BY: field,
91-
DIRECTION: 'ASC' // TODO This is not being passed to the FT.AGGREGATE command right now?
80+
BY: {
81+
BY: `@${field}`,
82+
DIRECTION: 'ASC'
83+
}
9284
},
9385
{
9486
type: AggregateSteps.LIMIT,

0 commit comments

Comments
 (0)