MCPcopy
hub / github.com/redis/go-redis / ExampleClient_query_range

Function ExampleClient_query_range

doctests/query_range_test.go:12–394  ·  doctests/query_range_test.go::ExampleClient_query_range
()

Source from the content-addressed store, hash-verified

10)
11
12func ExampleClient_query_range() {
13 ctx := context.Background()
14
15 rdb := redis.NewClient(&redis.Options{
16 Addr: "localhost:6379",
17 Password: "", // no password docs
18 DB: 0, // use default DB
19 Protocol: 2,
20 })
21
22 // HIDE_END
23 // REMOVE_START
24 rdb.FTDropIndex(ctx, "idx:bicycle")
25 rdb.FTDropIndex(ctx, "idx:email")
26 // REMOVE_END
27
28 _, err := rdb.FTCreate(ctx, "idx:bicycle",
29 &redis.FTCreateOptions{
30 OnJSON: true,
31 Prefix: []interface{}{"bicycle:"},
32 },
33 &redis.FieldSchema{
34 FieldName: "$.brand",
35 As: "brand",
36 FieldType: redis.SearchFieldTypeText,
37 },
38 &redis.FieldSchema{
39 FieldName: "$.model",
40 As: "model",
41 FieldType: redis.SearchFieldTypeText,
42 },
43 &redis.FieldSchema{
44 FieldName: "$.description",
45 As: "description",
46 FieldType: redis.SearchFieldTypeText,
47 },
48 &redis.FieldSchema{
49 FieldName: "$.price",
50 As: "price",
51 FieldType: redis.SearchFieldTypeNumeric,
52 },
53 &redis.FieldSchema{
54 FieldName: "$.condition",
55 As: "condition",
56 FieldType: redis.SearchFieldTypeTag,
57 },
58 ).Result()
59
60 if err != nil {
61 panic(err)
62 }
63
64 exampleJsons := []map[string]interface{}{
65 {
66 "pickup_zone": "POLYGON((-74.0610 40.7578, -73.9510 40.7578, -73.9510 40.6678, " +
67 "-74.0610 40.6678, -74.0610 40.7578))",
68 "store_location": "-74.0060,40.7128",
69 "brand": "Velorim",

Callers

nothing calls this directly

Calls 6

FTDropIndexMethod · 0.65
ResultMethod · 0.65
FTCreateMethod · 0.65
JSONSetMethod · 0.65
FTSearchWithArgsMethod · 0.65
PrintfMethod · 0.65

Tested by

no test coverage detected