@@ -114,6 +114,7 @@ type SpellCheckTerms struct {
114
114
}
115
115
116
116
type FTExplainOptions struct {
117
+ // Dialect 1,3 and 4 are deprecated since redis 8.0
117
118
Dialect string
118
119
}
119
120
@@ -261,7 +262,8 @@ type FTAggregateOptions struct {
261
262
WithCursor bool
262
263
WithCursorOptions * FTAggregateWithCursor
263
264
Params map [string ]interface {}
264
- DialectVersion int
265
+ // Dialect 1,3 and 4 are deprecated since redis 8.0
266
+ DialectVersion int
265
267
}
266
268
267
269
type FTSearchFilter struct {
@@ -320,8 +322,12 @@ type FTSearchOptions struct {
320
322
SortByWithCount bool
321
323
LimitOffset int
322
324
Limit int
323
- Params map [string ]interface {}
324
- DialectVersion int
325
+ // CountOnly sets LIMIT 0 0 to get the count - number of documents in the result set without actually returning the result set.
326
+ // When using this option, the Limit and LimitOffset options are ignored.
327
+ CountOnly bool
328
+ Params map [string ]interface {}
329
+ // Dialect 1,3 and 4 are deprecated since redis 8.0
330
+ DialectVersion int
325
331
}
326
332
327
333
type FTSynDumpResult struct {
@@ -437,7 +443,8 @@ type IndexDefinition struct {
437
443
type FTSpellCheckOptions struct {
438
444
Distance int
439
445
Terms * FTSpellCheckTerms
440
- Dialect int
446
+ // Dialect 1,3 and 4 are deprecated since redis 8.0
447
+ Dialect int
441
448
}
442
449
443
450
type FTSpellCheckTerms struct {
@@ -1954,8 +1961,12 @@ func (c cmdable) FTSearchWithArgs(ctx context.Context, index string, query strin
1954
1961
args = append (args , "WITHCOUNT" )
1955
1962
}
1956
1963
}
1957
- if options .LimitOffset >= 0 && options .Limit > 0 {
1958
- args = append (args , "LIMIT" , options .LimitOffset , options .Limit )
1964
+ if options .CountOnly {
1965
+ args = append (args , "LIMIT" , 0 , 0 )
1966
+ } else {
1967
+ if options .LimitOffset >= 0 && options .Limit > 0 || options .LimitOffset > 0 && options .Limit == 0 {
1968
+ args = append (args , "LIMIT" , options .LimitOffset , options .Limit )
1969
+ }
1959
1970
}
1960
1971
if options .Params != nil {
1961
1972
args = append (args , "PARAMS" , len (options .Params )* 2 )
@@ -2090,216 +2101,3 @@ func (c cmdable) FTTagVals(ctx context.Context, index string, field string) *Str
2090
2101
_ = c (ctx , cmd )
2091
2102
return cmd
2092
2103
}
2093
-
2094
- // TODO: remove FTProfile
2095
- // type FTProfileResult struct {
2096
- // Results []interface{}
2097
- // Profile ProfileDetails
2098
- // }
2099
-
2100
- // type ProfileDetails struct {
2101
- // TotalProfileTime string
2102
- // ParsingTime string
2103
- // PipelineCreationTime string
2104
- // Warning string
2105
- // IteratorsProfile []IteratorProfile
2106
- // ResultProcessorsProfile []ResultProcessorProfile
2107
- // }
2108
-
2109
- // type IteratorProfile struct {
2110
- // Type string
2111
- // QueryType string
2112
- // Time interface{}
2113
- // Counter int
2114
- // Term string
2115
- // Size int
2116
- // ChildIterators []IteratorProfile
2117
- // }
2118
-
2119
- // type ResultProcessorProfile struct {
2120
- // Type string
2121
- // Time interface{}
2122
- // Counter int
2123
- // }
2124
-
2125
- // func parseFTProfileResult(data []interface{}) (FTProfileResult, error) {
2126
- // var result FTProfileResult
2127
- // if len(data) < 2 {
2128
- // return result, fmt.Errorf("unexpected data length")
2129
- // }
2130
-
2131
- // // Parse results
2132
- // result.Results = data[0].([]interface{})
2133
-
2134
- // // Parse profile details
2135
- // profileData := data[1].([]interface{})
2136
- // profileDetails := ProfileDetails{}
2137
- // for i := 0; i < len(profileData); i += 2 {
2138
- // switch profileData[i].(string) {
2139
- // case "Total profile time":
2140
- // profileDetails.TotalProfileTime = profileData[i+1].(string)
2141
- // case "Parsing time":
2142
- // profileDetails.ParsingTime = profileData[i+1].(string)
2143
- // case "Pipeline creation time":
2144
- // profileDetails.PipelineCreationTime = profileData[i+1].(string)
2145
- // case "Warning":
2146
- // profileDetails.Warning = profileData[i+1].(string)
2147
- // case "Iterators profile":
2148
- // profileDetails.IteratorsProfile = parseIteratorsProfile(profileData[i+1].([]interface{}))
2149
- // case "Result processors profile":
2150
- // profileDetails.ResultProcessorsProfile = parseResultProcessorsProfile(profileData[i+1].([]interface{}))
2151
- // }
2152
- // }
2153
-
2154
- // result.Profile = profileDetails
2155
- // return result, nil
2156
- // }
2157
-
2158
- // func parseIteratorsProfile(data []interface{}) []IteratorProfile {
2159
- // var iterators []IteratorProfile
2160
- // for _, item := range data {
2161
- // profile := item.([]interface{})
2162
- // iterator := IteratorProfile{}
2163
- // for i := 0; i < len(profile); i += 2 {
2164
- // switch profile[i].(string) {
2165
- // case "Type":
2166
- // iterator.Type = profile[i+1].(string)
2167
- // case "Query type":
2168
- // iterator.QueryType = profile[i+1].(string)
2169
- // case "Time":
2170
- // iterator.Time = profile[i+1]
2171
- // case "Counter":
2172
- // iterator.Counter = int(profile[i+1].(int64))
2173
- // case "Term":
2174
- // iterator.Term = profile[i+1].(string)
2175
- // case "Size":
2176
- // iterator.Size = int(profile[i+1].(int64))
2177
- // case "Child iterators":
2178
- // iterator.ChildIterators = parseChildIteratorsProfile(profile[i+1].([]interface{}))
2179
- // }
2180
- // }
2181
- // iterators = append(iterators, iterator)
2182
- // }
2183
- // return iterators
2184
- // }
2185
-
2186
- // func parseChildIteratorsProfile(data []interface{}) []IteratorProfile {
2187
- // var iterators []IteratorProfile
2188
- // for _, item := range data {
2189
- // profile := item.([]interface{})
2190
- // iterator := IteratorProfile{}
2191
- // for i := 0; i < len(profile); i += 2 {
2192
- // switch profile[i].(string) {
2193
- // case "Type":
2194
- // iterator.Type = profile[i+1].(string)
2195
- // case "Query type":
2196
- // iterator.QueryType = profile[i+1].(string)
2197
- // case "Time":
2198
- // iterator.Time = profile[i+1]
2199
- // case "Counter":
2200
- // iterator.Counter = int(profile[i+1].(int64))
2201
- // case "Term":
2202
- // iterator.Term = profile[i+1].(string)
2203
- // case "Size":
2204
- // iterator.Size = int(profile[i+1].(int64))
2205
- // }
2206
- // }
2207
- // iterators = append(iterators, iterator)
2208
- // }
2209
- // return iterators
2210
- // }
2211
-
2212
- // func parseResultProcessorsProfile(data []interface{}) []ResultProcessorProfile {
2213
- // var processors []ResultProcessorProfile
2214
- // for _, item := range data {
2215
- // profile := item.([]interface{})
2216
- // processor := ResultProcessorProfile{}
2217
- // for i := 0; i < len(profile); i += 2 {
2218
- // switch profile[i].(string) {
2219
- // case "Type":
2220
- // processor.Type = profile[i+1].(string)
2221
- // case "Time":
2222
- // processor.Time = profile[i+1]
2223
- // case "Counter":
2224
- // processor.Counter = int(profile[i+1].(int64))
2225
- // }
2226
- // }
2227
- // processors = append(processors, processor)
2228
- // }
2229
- // return processors
2230
- // }
2231
-
2232
- // func NewFTProfileCmd(ctx context.Context, args ...interface{}) *FTProfileCmd {
2233
- // return &FTProfileCmd{
2234
- // baseCmd: baseCmd{
2235
- // ctx: ctx,
2236
- // args: args,
2237
- // },
2238
- // }
2239
- // }
2240
-
2241
- // type FTProfileCmd struct {
2242
- // baseCmd
2243
- // val FTProfileResult
2244
- // }
2245
-
2246
- // func (cmd *FTProfileCmd) String() string {
2247
- // return cmdString(cmd, cmd.val)
2248
- // }
2249
-
2250
- // func (cmd *FTProfileCmd) SetVal(val FTProfileResult) {
2251
- // cmd.val = val
2252
- // }
2253
-
2254
- // func (cmd *FTProfileCmd) Result() (FTProfileResult, error) {
2255
- // return cmd.val, cmd.err
2256
- // }
2257
-
2258
- // func (cmd *FTProfileCmd) Val() FTProfileResult {
2259
- // return cmd.val
2260
- // }
2261
-
2262
- // func (cmd *FTProfileCmd) readReply(rd *proto.Reader) (err error) {
2263
- // data, err := rd.ReadSlice()
2264
- // if err != nil {
2265
- // return err
2266
- // }
2267
- // cmd.val, err = parseFTProfileResult(data)
2268
- // if err != nil {
2269
- // cmd.err = err
2270
- // }
2271
- // return nil
2272
- // }
2273
-
2274
- // // FTProfile - Executes a search query and returns a profile of how the query was processed.
2275
- // // The 'index' parameter specifies the index to search, the 'limited' parameter specifies whether to limit the results,
2276
- // // and the 'query' parameter specifies the search / aggreagte query. Please notice that you must either pass a SearchQuery or an AggregateQuery.
2277
- // // For more information, please refer to the Redis documentation:
2278
- // // [FT.PROFILE]: (https://redis.io/commands/ft.profile/)
2279
- // func (c cmdable) FTProfile(ctx context.Context, index string, limited bool, query interface{}) *FTProfileCmd {
2280
- // queryType := ""
2281
- // var argsQuery []interface{}
2282
-
2283
- // switch v := query.(type) {
2284
- // case AggregateQuery:
2285
- // queryType = "AGGREGATE"
2286
- // argsQuery = v
2287
- // case SearchQuery:
2288
- // queryType = "SEARCH"
2289
- // argsQuery = v
2290
- // default:
2291
- // panic("FT.PROFILE: query must be either AggregateQuery or SearchQuery")
2292
- // }
2293
-
2294
- // args := []interface{}{"FT.PROFILE", index, queryType}
2295
-
2296
- // if limited {
2297
- // args = append(args, "LIMITED")
2298
- // }
2299
- // args = append(args, "QUERY")
2300
- // args = append(args, argsQuery...)
2301
-
2302
- // cmd := NewFTProfileCmd(ctx, args...)
2303
- // _ = c(ctx, cmd)
2304
- // return cmd
2305
- // }
0 commit comments