mirror of
https://github.com/redis/go-redis.git
synced 2025-04-19 07:22:17 +03:00
Add more tests and comments on deprecated params
This commit is contained in:
parent
02c3494bb9
commit
bc92d04536
@ -114,6 +114,7 @@ type SpellCheckTerms struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type FTExplainOptions struct {
|
type FTExplainOptions struct {
|
||||||
|
// Dialect 1,3 and 4 are deprecated since redis 8.0
|
||||||
Dialect string
|
Dialect string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,7 +262,8 @@ type FTAggregateOptions struct {
|
|||||||
WithCursor bool
|
WithCursor bool
|
||||||
WithCursorOptions *FTAggregateWithCursor
|
WithCursorOptions *FTAggregateWithCursor
|
||||||
Params map[string]interface{}
|
Params map[string]interface{}
|
||||||
DialectVersion int
|
// Dialect 1,3 and 4 are deprecated since redis 8.0
|
||||||
|
DialectVersion int
|
||||||
}
|
}
|
||||||
|
|
||||||
type FTSearchFilter struct {
|
type FTSearchFilter struct {
|
||||||
@ -293,8 +295,9 @@ type FTSearchSortBy struct {
|
|||||||
// More information about the options can be found
|
// More information about the options can be found
|
||||||
// in the documentation for FT.SEARCH https://redis.io/docs/latest/commands/ft.search/
|
// in the documentation for FT.SEARCH https://redis.io/docs/latest/commands/ft.search/
|
||||||
type FTSearchOptions struct {
|
type FTSearchOptions struct {
|
||||||
NoContent bool
|
NoContent bool
|
||||||
Verbatim bool
|
Verbatim bool
|
||||||
|
// NoStopWords is deprecated since redis 8.0
|
||||||
NoStopWords bool
|
NoStopWords bool
|
||||||
WithScores bool
|
WithScores bool
|
||||||
WithPayloads bool
|
WithPayloads bool
|
||||||
@ -322,8 +325,9 @@ type FTSearchOptions struct {
|
|||||||
Limit int
|
Limit int
|
||||||
// CountOnly sets LIMIT 0 0 to get the count - number of documents in the result set without actually returning the result set.
|
// CountOnly sets LIMIT 0 0 to get the count - number of documents in the result set without actually returning the result set.
|
||||||
// When using this option, the Limit and LimitOffset options are ignored.
|
// When using this option, the Limit and LimitOffset options are ignored.
|
||||||
CountOnly bool
|
CountOnly bool
|
||||||
Params map[string]interface{}
|
Params map[string]interface{}
|
||||||
|
// Dialect 1,3 and 4 are deprecated since redis 8.0
|
||||||
DialectVersion int
|
DialectVersion int
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,7 +444,8 @@ type IndexDefinition struct {
|
|||||||
type FTSpellCheckOptions struct {
|
type FTSpellCheckOptions struct {
|
||||||
Distance int
|
Distance int
|
||||||
Terms *FTSpellCheckTerms
|
Terms *FTSpellCheckTerms
|
||||||
Dialect int
|
// Dialect 1,3 and 4 are deprecated since redis 8.0
|
||||||
|
Dialect int
|
||||||
}
|
}
|
||||||
|
|
||||||
type FTSpellCheckTerms struct {
|
type FTSpellCheckTerms struct {
|
||||||
|
@ -1684,7 +1684,6 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
|
|||||||
Expect(resUint8.Docs[0].ID).To(BeEquivalentTo("doc1"))
|
Expect(resUint8.Docs[0].ID).To(BeEquivalentTo("doc1"))
|
||||||
})
|
})
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
It("should fail when using a non-zero offset with a zero limit", Label("search", "ftsearch"), func() {
|
It("should fail when using a non-zero offset with a zero limit", Label("search", "ftsearch"), func() {
|
||||||
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
|
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
|
||||||
val, err := client.FTCreate(ctx, "testIdx", &redis.FTCreateOptions{}, &redis.FieldSchema{
|
val, err := client.FTCreate(ctx, "testIdx", &redis.FTCreateOptions{}, &redis.FieldSchema{
|
||||||
@ -2106,6 +2105,99 @@ var _ = Describe("RediSearch commands Resp 2", Label("search"), func() {
|
|||||||
Expect(len(resLimit.Docs)).To(BeEquivalentTo(2))
|
Expect(len(resLimit.Docs)).To(BeEquivalentTo(2))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should reject deprecated configuration keys", Label("search", "ftconfig"), func() {
|
||||||
|
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
|
||||||
|
// List of deprecated configuration keys.
|
||||||
|
deprecatedKeys := []string{
|
||||||
|
"_FREE_RESOURCE_ON_THREAD",
|
||||||
|
"_NUMERIC_COMPRESS",
|
||||||
|
"_NUMERIC_RANGES_PARENTS",
|
||||||
|
"_PRINT_PROFILE_CLOCK",
|
||||||
|
"_PRIORITIZE_INTERSECT_UNION_CHILDREN",
|
||||||
|
"BG_INDEX_SLEEP_GAP",
|
||||||
|
"CONN_PER_SHARD",
|
||||||
|
"CURSOR_MAX_IDLE",
|
||||||
|
"CURSOR_REPLY_THRESHOLD",
|
||||||
|
"DEFAULT_DIALECT",
|
||||||
|
"EXTLOAD",
|
||||||
|
"FORK_GC_CLEAN_THRESHOLD",
|
||||||
|
"FORK_GC_RETRY_INTERVAL",
|
||||||
|
"FORK_GC_RUN_INTERVAL",
|
||||||
|
"FORKGC_SLEEP_BEFORE_EXIT",
|
||||||
|
"FRISOINI",
|
||||||
|
"GC_POLICY",
|
||||||
|
"GCSCANSIZE",
|
||||||
|
"INDEX_CURSOR_LIMIT",
|
||||||
|
"MAXAGGREGATERESULTS",
|
||||||
|
"MAXDOCTABLESIZE",
|
||||||
|
"MAXPREFIXEXPANSIONS",
|
||||||
|
"MAXSEARCHRESULTS",
|
||||||
|
"MIN_OPERATION_WORKERS",
|
||||||
|
"MIN_PHONETIC_TERM_LEN",
|
||||||
|
"MINPREFIX",
|
||||||
|
"MINSTEMLEN",
|
||||||
|
"NO_MEM_POOLS",
|
||||||
|
"NOGC",
|
||||||
|
"ON_TIMEOUT",
|
||||||
|
"MULTI_TEXT_SLOP",
|
||||||
|
"PARTIAL_INDEXED_DOCS",
|
||||||
|
"RAW_DOCID_ENCODING",
|
||||||
|
"SEARCH_THREADS",
|
||||||
|
"TIERED_HNSW_BUFFER_LIMIT",
|
||||||
|
"TIMEOUT",
|
||||||
|
"TOPOLOGY_VALIDATION_TIMEOUT",
|
||||||
|
"UNION_ITERATOR_HEAP",
|
||||||
|
"VSS_MAX_RESIZE",
|
||||||
|
"WORKERS",
|
||||||
|
"WORKERS_PRIORITY_BIAS_THRESHOLD",
|
||||||
|
"MT_MODE",
|
||||||
|
"WORKER_THREADS",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, key := range deprecatedKeys {
|
||||||
|
_, err := client.FTConfigSet(ctx, key, "test_value").Result()
|
||||||
|
Expect(err).To(HaveOccurred())
|
||||||
|
}
|
||||||
|
|
||||||
|
val, err := client.ConfigGet(ctx, "*").Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
// Since FT.CONFIG is deprecated since redis 8, use CONFIG instead with new search parameters.
|
||||||
|
keys := make([]string, 0, len(val))
|
||||||
|
for key := range val {
|
||||||
|
keys = append(keys, key)
|
||||||
|
}
|
||||||
|
Expect(keys).To(ContainElement(ContainSubstring("search")))
|
||||||
|
})
|
||||||
|
|
||||||
|
It("should return INF for MIN reducer and -INF for MAX reducer when no numeric values are present", Label("search", "ftaggregate"), func() {
|
||||||
|
SkipBeforeRedisVersion(7.9, "requires Redis 8.x")
|
||||||
|
val, err := client.FTCreate(ctx, "aggTestMinMax", &redis.FTCreateOptions{},
|
||||||
|
&redis.FieldSchema{FieldName: "grp", FieldType: redis.SearchFieldTypeText},
|
||||||
|
&redis.FieldSchema{FieldName: "n", FieldType: redis.SearchFieldTypeNumeric},
|
||||||
|
).Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(val).To(BeEquivalentTo("OK"))
|
||||||
|
WaitForIndexing(client, "aggTestMinMax")
|
||||||
|
|
||||||
|
_, err = client.HSet(ctx, "doc1", "grp", "g1").Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
|
reducers := []redis.FTAggregateReducer{
|
||||||
|
{Reducer: redis.SearchMin, Args: []interface{}{"@n"}, As: "minValue"},
|
||||||
|
{Reducer: redis.SearchMax, Args: []interface{}{"@n"}, As: "maxValue"},
|
||||||
|
}
|
||||||
|
groupBy := []redis.FTAggregateGroupBy{
|
||||||
|
{Fields: []interface{}{"@grp"}, Reduce: reducers},
|
||||||
|
}
|
||||||
|
options := &redis.FTAggregateOptions{GroupBy: groupBy}
|
||||||
|
res, err := client.FTAggregateWithArgs(ctx, "aggTestMinMax", "*", options).Result()
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
Expect(res.Rows).ToNot(BeEmpty())
|
||||||
|
|
||||||
|
Expect(res.Rows[0].Fields["minValue"]).To(BeEquivalentTo("inf"))
|
||||||
|
Expect(res.Rows[0].Fields["maxValue"]).To(BeEquivalentTo("-inf"))
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
func _assert_geosearch_result(result *redis.FTSearchResult, expectedDocIDs []string) {
|
func _assert_geosearch_result(result *redis.FTSearchResult, expectedDocIDs []string) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user