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