Skip to content

Commit 1482220

Browse files
Merge pull request #1126 from redis/DOC-4809-go-query-resp2-note
DOC-4809 Go query engine RESP2 note
2 parents 49ade7d + 915cb18 commit 1482220

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

content/develop/clients/go/queryjson.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,36 @@ Connect to the database:
3131
{{< clients-example go_home_json connect >}}
3232
{{< /clients-example >}}
3333

34+
{{< note >}}The connection options in the example specify
35+
[RESP2]({{< relref "/develop/reference/protocol-spec" >}}) in the `Protocol`
36+
field. We recommend that you use RESP2 for Redis query engine operations in `go-redis`
37+
because some of the response structures for the default RESP3 are currently
38+
incomplete and so you must handle the "raw" responses in your own code.
39+
40+
If you do want to use RESP3, you should set the `UnstableResp3` option when
41+
you connect:
42+
43+
```go
44+
rdb := redis.NewClient(&redis.Options{
45+
UnstableResp3: true,
46+
// Other options...
47+
})
48+
```
49+
50+
You must also access command results using the `RawResult()` and `RawVal()` methods
51+
rather than the usual `Result()` and `Val()`:
52+
53+
```go
54+
res1, err := client.FTSearchWithArgs(
55+
ctx, "txt", "foo bar", &redis.FTSearchOptions{},
56+
).RawResult()
57+
val1 := client.FTSearchWithArgs(
58+
ctx, "txt", "foo bar", &redis.FTSearchOptions{},
59+
).RawVal()
60+
```
61+
{{< /note >}}
62+
63+
3464
Create some test data to add to the database:
3565

3666
{{< clients-example go_home_json create_data >}}

0 commit comments

Comments
 (0)