mirror of
https://github.com/redis/go-redis.git
synced 2025-07-29 17:41:15 +03:00
fix(tests): enable testing with Redis CE 8.0-M4 in CI (#3247)
* introduce github workflow for ci similar to the one in redis-py use prerelease for 8.0-M4 * Enable osscluster tests in CI * Add redis major version env Enable filtering test per redis major version Fix test for FT.SEARCH WITHSCORE, the default scorer has changed. fix Makefile syntax remove filter from github action fix makefile use the container name in Makefile * remove 1.20 from doctests * self review, cleanup, add comments * add comments, reorder prints, add default value for REDIS_MAJOR_VERSION
This commit is contained in:
@ -371,7 +371,56 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
|
||||
Expect(names).To(ContainElement("John"))
|
||||
})
|
||||
|
||||
// up until redis 8 the default scorer was TFIDF, in redis 8 it is BM25
|
||||
// this test expect redis major version >= 8
|
||||
It("should FTSearch WithScores", Label("search", "ftsearch"), func() {
|
||||
if REDIS_MAJOR_VERSION < 8 {
|
||||
Skip("(redis major version < 8) default scorer is not BM25")
|
||||
}
|
||||
text1 := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText}
|
||||
val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, text1).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(val).To(BeEquivalentTo("OK"))
|
||||
WaitForIndexing(client, "idx1")
|
||||
|
||||
client.HSet(ctx, "doc1", "description", "The quick brown fox jumps over the lazy dog")
|
||||
client.HSet(ctx, "doc2", "description", "Quick alice was beginning to get very tired of sitting by her quick sister on the bank, and of having nothing to do.")
|
||||
|
||||
res, err := client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeNumerically("<=", 0.236))
|
||||
|
||||
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "TFIDF"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeEquivalentTo(float64(1)))
|
||||
|
||||
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "TFIDF.DOCNORM"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeEquivalentTo(0.14285714285714285))
|
||||
|
||||
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "BM25"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeNumerically("<=", 0.22471909420069797))
|
||||
|
||||
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "DISMAX"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeEquivalentTo(float64(2)))
|
||||
|
||||
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "DOCSCORE"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeEquivalentTo(float64(1)))
|
||||
|
||||
res, err = client.FTSearchWithArgs(ctx, "idx1", "quick", &redis.FTSearchOptions{WithScores: true, Scorer: "HAMMING"}).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(*res.Docs[0].Score).To(BeEquivalentTo(float64(0)))
|
||||
})
|
||||
|
||||
// up until redis 8 the default scorer was TFIDF, in redis 8 it is BM25
|
||||
// this test expect redis major version <=7
|
||||
It("should FTSearch WithScores", Label("search", "ftsearch"), func() {
|
||||
if REDIS_MAJOR_VERSION > 7 {
|
||||
Skip("(redis major version > 7) default scorer is not TFIDF")
|
||||
}
|
||||
text1 := &redis.FieldSchema{FieldName: "description", FieldType: redis.SearchFieldTypeText}
|
||||
val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, text1).Result()
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
Reference in New Issue
Block a user