Skip to content

Commit 183ca5d

Browse files
committed
Test dialect 4
1 parent 67824eb commit 183ca5d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

search_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,57 @@ var _ = Describe("RediSearch commands", Label("search"), func() {
10171017
Expect(res.Attributes[0].WithSuffixtrie).To(BeTrue())
10181018
})
10191019

1020+
It("should test dialect 4", Label("search", "ftcreate", "ftsearch"), func() {
1021+
val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{
1022+
Prefix: []interface{}{"resource:"},
1023+
}, &redis.FieldSchema{
1024+
FieldName: "uuid",
1025+
FieldType: redis.SearchFieldTypeTag,
1026+
}, &redis.FieldSchema{
1027+
FieldName: "tags",
1028+
FieldType: redis.SearchFieldTypeTag,
1029+
}, &redis.FieldSchema{
1030+
FieldName: "description",
1031+
FieldType: redis.SearchFieldTypeText,
1032+
}, &redis.FieldSchema{
1033+
FieldName: "rating",
1034+
FieldType: redis.SearchFieldTypeNumeric,
1035+
}).Result()
1036+
Expect(err).NotTo(HaveOccurred())
1037+
Expect(val).To(BeEquivalentTo("OK"))
1038+
1039+
client.HSet(ctx, "resource:1", map[string]interface{}{
1040+
"uuid": "123e4567-e89b-12d3-a456-426614174000",
1041+
"tags": "finance|crypto|$btc|blockchain",
1042+
"description": "Analysis of blockchain technologies & Bitcoin's potential.",
1043+
"rating": 5,
1044+
})
1045+
client.HSet(ctx, "resource:2", map[string]interface{}{
1046+
"uuid": "987e6543-e21c-12d3-a456-426614174999",
1047+
"tags": "health|well-being|fitness|new-year's-resolutions",
1048+
"description": "Health trends for the new year, including fitness regimes.",
1049+
"rating": 4,
1050+
})
1051+
1052+
res, err := client.FTSearchWithArgs(ctx, "idx1", "@uuid:{$uuid}",
1053+
&redis.FTSearchOptions{
1054+
DialectVersion: 2,
1055+
Params: map[string]interface{}{"uuid": "123e4567-e89b-12d3-a456-426614174000"},
1056+
}).Result()
1057+
Expect(err).NotTo(HaveOccurred())
1058+
Expect(res.Total).To(BeEquivalentTo(int64(1)))
1059+
Expect(res.Docs[0].ID).To(BeEquivalentTo("resource:1"))
1060+
1061+
res, err = client.FTSearchWithArgs(ctx, "idx1", "@uuid:{$uuid}",
1062+
&redis.FTSearchOptions{
1063+
DialectVersion: 4,
1064+
Params: map[string]interface{}{"uuid": "123e4567-e89b-12d3-a456-426614174000"},
1065+
}).Result()
1066+
Expect(err).NotTo(HaveOccurred())
1067+
Expect(res.Total).To(BeEquivalentTo(int64(1)))
1068+
Expect(res.Docs[0].ID).To(BeEquivalentTo("resource:1"))
1069+
})
1070+
10201071
It("should FTCreate GeoShape", Label("search", "ftcreate", "ftsearch"), func() {
10211072
val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "geom", FieldType: redis.SearchFieldTypeGeoShape, GeoShapeFieldType: "FLAT"}).Result()
10221073
Expect(err).NotTo(HaveOccurred())

0 commit comments

Comments
 (0)