@@ -3,11 +3,11 @@ package redisearch
33import  (
44	"errors" 
55	"fmt" 
6+ 	"github.com/gomodule/redigo/redis" 
7+ 	"log" 
68	"reflect" 
79	"strconv" 
810	"strings" 
9- 	"log" 
10- 	"github.com/gomodule/redigo/redis" 
1111)
1212
1313// Options are flags passed to the the abstract Index call, which receives them as interface{}, allowing 
@@ -399,7 +399,7 @@ func (i *Client) Aggregate(q *AggregateQuery) (aggregateReply [][]string, total
399399	hasCursor  :=  q .WithCursor 
400400	validCursor  :=  q .CursorHasResults ()
401401	var  res  []interface {} =  nil 
402- 	if  !   validCursor  {
402+ 	if  ! validCursor  {
403403		args  :=  redis.Args {i .name }
404404		args  =  append (args , q .Serialize ()... )
405405		res , err  =  redis .Values (conn .Do ("FT.AGGREGATE" , args ... ))
@@ -411,9 +411,11 @@ func (i *Client) Aggregate(q *AggregateQuery) (aggregateReply [][]string, total
411411		return 
412412	}
413413	// has no cursor 
414- 	if  !   hasCursor  {
414+ 	if  ! hasCursor  {
415415		total  =  len (res ) -  1 
416- 		if  total  >  1  {
416+ 		// there is a case when only 1 data from aggregate, it returns nothing 
417+ 		// then set total > 0 so the data will be return 
418+ 		if  total  >  0  {
417419			aggregateReply  =  ProcessAggResponse (res [1 :])
418420		}
419421		// has cursor 
@@ -427,7 +429,9 @@ func (i *Client) Aggregate(q *AggregateQuery) (aggregateReply [][]string, total
427429			return  aggregateReply , total , err 
428430		}
429431		total  =  len (partialResults ) -  1 
430- 		if  total  >  1  {
432+ 		// there is a case when only 1 data from aggregate, it returns nothing 
433+ 		// then set total > 0 so the data will be return 
434+ 		if  total  >  0  {
431435			aggregateReply  =  ProcessAggResponse (partialResults [1 :])
432436		}
433437	}
0 commit comments