Skip to content

Commit 7d88815

Browse files
Christopher GollingChristopher Golling
Christopher Golling
authored and
Christopher Golling
committed
SortByWithCount FTSearchOptions fix
1 parent e63669e commit 7d88815

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

search_commands.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1775,7 +1775,7 @@ func FTSearchQuery(query string, options *FTSearchOptions) SearchQuery {
17751775
}
17761776
}
17771777
if options.SortByWithCount {
1778-
queryArgs = append(queryArgs, "WITHCOUT")
1778+
queryArgs = append(queryArgs, "WITHCOUNT")
17791779
}
17801780
}
17811781
if options.LimitOffset >= 0 && options.Limit > 0 {

search_test.go

+7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
125125
Expect(res2.Docs[1].ID).To(BeEquivalentTo("doc2"))
126126
Expect(res2.Docs[0].ID).To(BeEquivalentTo("doc3"))
127127

128+
res3, err := client.FTSearchWithArgs(ctx, "num", "foo", &redis.FTSearchOptions{NoContent: true, SortBy: []redis.FTSearchSortBy{sortBy2}, SortByWithCount: true}).Result()
129+
Expect(err).NotTo(HaveOccurred())
130+
Expect(res3.Total).To(BeEquivalentTo(int64(3)))
131+
Expect(res3.Docs[2].ID).To(BeEquivalentTo("doc1"))
132+
Expect(res3.Docs[1].ID).To(BeEquivalentTo("doc2"))
133+
Expect(res3.Docs[0].ID).To(BeEquivalentTo("doc3"))
134+
128135
})
129136

130137
It("should FTCreate and FTSearch example", Label("search", "ftcreate", "ftsearch"), func() {

0 commit comments

Comments
 (0)