I’m able to create an index and load data using go-redis. Also, I’m able to search but only via CLI. That means the index is created properly and is searchable. It returns the correct results.
But when I try to search the data programmatically, it returns:
redis: 2024/07/26 19:27:10 pool.go:368: Conn has unread data
{Total:0 Docs:[]}
I’m using the following example: https://github.com/redis/go-redis/blob/master/search_test.go#L128-L138
Code used for reference:
// Create index
_, err := client.FTCreate(ctx, "txt", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "txt", FieldType: redis.SearchFieldTypeText}).Result()
// Add data
client.HSet(ctx, "doc1", "txt", "foo baz")
client.HSet(ctx, "doc2", "txt", "foo bar")
// Search
res, err := client.FTSearchWithArgs(ctx, "txt", "foo ~bar", &redis.FTSearchOptions{WithScores: true, Limit: 50}).Result()
if err != nil {
fmt.Printf("nerr: %v", err)
}
Can anyone help me understand what’s going wrong here?