Skip to content

Commit dd8ba4d

Browse files
authored
Merge branch 'master' into ndyakov/update-readme-discord
2 parents 93b822e + e191cf9 commit dd8ba4d

File tree

7 files changed

+629
-24
lines changed

7 files changed

+629
-24
lines changed

doctests/home_json_example_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,32 @@ func ExampleClient_search_json() {
152152
// >>> Tel Aviv
153153
// STEP_END
154154

155+
// STEP_START query2count_only
156+
citiesResult2, err := rdb.FTSearchWithArgs(
157+
ctx,
158+
"idx:users",
159+
"Paul",
160+
&redis.FTSearchOptions{
161+
Return: []redis.FTSearchReturn{
162+
{
163+
FieldName: "$.city",
164+
As: "city",
165+
},
166+
},
167+
CountOnly: true,
168+
},
169+
).Result()
170+
171+
if err != nil {
172+
panic(err)
173+
}
174+
175+
// The `Total` field has the correct number of docs found
176+
// by the query but the `Docs` slice is empty.
177+
fmt.Println(len(citiesResult2.Docs)) // >>> 0
178+
fmt.Println(citiesResult2.Total) // >>> 2
179+
// STEP_END
180+
155181
// STEP_START query3
156182
aggOptions := redis.FTAggregateOptions{
157183
GroupBy: []redis.FTAggregateGroupBy{
@@ -196,6 +222,8 @@ func ExampleClient_search_json() {
196222
// {1 [{user:3 <nil> <nil> <nil> map[$:{"age":35,"city":"Tel Aviv","email":"[email protected]","name":"Paul Zamir"}]}]}
197223
// London
198224
// Tel Aviv
225+
// 0
226+
// 2
199227
// London - 1
200228
// Tel Aviv - 2
201229
}

internal_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,27 @@ var _ = Describe("withConn", func() {
352352
Expect(client.connPool.Len()).To(Equal(1))
353353
})
354354
})
355+
356+
var _ = Describe("ClusterClient", func() {
357+
var client *ClusterClient
358+
359+
BeforeEach(func() {
360+
client = &ClusterClient{}
361+
})
362+
363+
Describe("cmdSlot", func() {
364+
It("select slot from args for GETKEYSINSLOT command", func() {
365+
cmd := NewStringSliceCmd(ctx, "cluster", "getkeysinslot", 100, 200)
366+
367+
slot := client.cmdSlot(context.Background(), cmd)
368+
Expect(slot).To(Equal(100))
369+
})
370+
371+
It("select slot from args for COUNTKEYSINSLOT command", func() {
372+
cmd := NewStringSliceCmd(ctx, "cluster", "countkeysinslot", 100)
373+
374+
slot := client.cmdSlot(context.Background(), cmd)
375+
Expect(slot).To(Equal(100))
376+
})
377+
})
378+
})

osscluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1856,7 +1856,7 @@ func (c *ClusterClient) cmdInfo(ctx context.Context, name string) *CommandInfo {
18561856

18571857
func (c *ClusterClient) cmdSlot(ctx context.Context, cmd Cmder) int {
18581858
args := cmd.Args()
1859-
if args[0] == "cluster" && args[1] == "getkeysinslot" {
1859+
if args[0] == "cluster" && (args[1] == "getkeysinslot" || args[1] == "countkeysinslot") {
18601860
return args[2].(int)
18611861
}
18621862

search_commands.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type SpellCheckTerms struct {
114114
}
115115

116116
type FTExplainOptions struct {
117+
// Dialect 1,3 and 4 are deprecated since redis 8.0
117118
Dialect string
118119
}
119120

@@ -261,7 +262,8 @@ type FTAggregateOptions struct {
261262
WithCursor bool
262263
WithCursorOptions *FTAggregateWithCursor
263264
Params map[string]interface{}
264-
DialectVersion int
265+
// Dialect 1,3 and 4 are deprecated since redis 8.0
266+
DialectVersion int
265267
}
266268

267269
type FTSearchFilter struct {
@@ -322,8 +324,9 @@ type FTSearchOptions struct {
322324
Limit int
323325
// CountOnly sets LIMIT 0 0 to get the count - number of documents in the result set without actually returning the result set.
324326
// When using this option, the Limit and LimitOffset options are ignored.
325-
CountOnly bool
326-
Params map[string]interface{}
327+
CountOnly bool
328+
Params map[string]interface{}
329+
// Dialect 1,3 and 4 are deprecated since redis 8.0
327330
DialectVersion int
328331
}
329332

@@ -440,7 +443,8 @@ type IndexDefinition struct {
440443
type FTSpellCheckOptions struct {
441444
Distance int
442445
Terms *FTSpellCheckTerms
443-
Dialect int
446+
// Dialect 1,3 and 4 are deprecated since redis 8.0
447+
Dialect int
444448
}
445449

446450
type FTSpellCheckTerms struct {

0 commit comments

Comments
 (0)