Created
May 15, 2023 12:51
-
-
Save rueian/82a3808d17d53dc35dbc9de71fb686e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"context" | |
"fmt" | |
"github.com/redis/rueidis" | |
) | |
func main() { | |
client, err := rueidis.NewClient(rueidis.ClientOption{InitAddress: []string{"127.0.0.1:6377"}}) | |
if err != nil { | |
panic(err) | |
} | |
defer client.Close() | |
ctx := context.Background() | |
if err = client.Do(ctx, client.B().FtCreate().Index("users").OnHash().Prefix(1). | |
Prefix("users:").Schema().FieldName("groups").Tag().Separator(",").Build()).Error(); err != nil { | |
fmt.Println(err) | |
} | |
if err = client.Do(ctx, client.B().Hset().Key("users:1").FieldValue().FieldValue("groups", "1,2,3").Build()).Error(); err != nil { | |
fmt.Println(err) | |
} | |
if err = client.Do(ctx, client.B().Hset().Key("users:a").FieldValue().FieldValue("groups", "a,b,c").Build()).Error(); err != nil { | |
fmt.Println(err) | |
} | |
fmt.Println(client.Do(ctx, client.B().FtSearch().Index("users").Query("@groups:{ 1 }").Build()).AsFtSearch()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment