Skip to content

Commit 8e020c1

Browse files
authored
drop ft.profile that was never enabled (#3323)
1 parent 0df0f3c commit 8e020c1

File tree

2 files changed

+0
-303
lines changed

2 files changed

+0
-303
lines changed

search_commands.go

-213
Original file line numberDiff line numberDiff line change
@@ -2090,216 +2090,3 @@ func (c cmdable) FTTagVals(ctx context.Context, index string, field string) *Str
20902090
_ = c(ctx, cmd)
20912091
return cmd
20922092
}
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-
// }

search_test.go

-90
Original file line numberDiff line numberDiff line change
@@ -1694,96 +1694,6 @@ func _assert_geosearch_result(result *redis.FTSearchResult, expectedDocIDs []str
16941694
Expect(result.Total).To(BeEquivalentTo(len(expectedDocIDs)))
16951695
}
16961696

1697-
// It("should FTProfile Search and Aggregate", Label("search", "ftprofile"), func() {
1698-
// val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "t", FieldType: redis.SearchFieldTypeText}).Result()
1699-
// Expect(err).NotTo(HaveOccurred())
1700-
// Expect(val).To(BeEquivalentTo("OK"))
1701-
// WaitForIndexing(client, "idx1")
1702-
1703-
// client.HSet(ctx, "1", "t", "hello")
1704-
// client.HSet(ctx, "2", "t", "world")
1705-
1706-
// // FTProfile Search
1707-
// query := redis.FTSearchQuery("hello|world", &redis.FTSearchOptions{NoContent: true})
1708-
// res1, err := client.FTProfile(ctx, "idx1", false, query).Result()
1709-
// Expect(err).NotTo(HaveOccurred())
1710-
// panic(res1)
1711-
// Expect(len(res1["results"].([]interface{}))).To(BeEquivalentTo(3))
1712-
// resProfile := res1["profile"].(map[interface{}]interface{})
1713-
// Expect(resProfile["Parsing time"].(float64) < 0.5).To(BeTrue())
1714-
// iterProfile0 := resProfile["Iterators profile"].([]interface{})[0].(map[interface{}]interface{})
1715-
// Expect(iterProfile0["Counter"]).To(BeEquivalentTo(2.0))
1716-
// Expect(iterProfile0["Type"]).To(BeEquivalentTo("UNION"))
1717-
1718-
// // FTProfile Aggregate
1719-
// aggQuery := redis.FTAggregateQuery("*", &redis.FTAggregateOptions{
1720-
// Load: []redis.FTAggregateLoad{{Field: "t"}},
1721-
// Apply: []redis.FTAggregateApply{{Field: "startswith(@t, 'hel')", As: "prefix"}}})
1722-
// res2, err := client.FTProfile(ctx, "idx1", false, aggQuery).Result()
1723-
// Expect(err).NotTo(HaveOccurred())
1724-
// Expect(len(res2["results"].([]interface{}))).To(BeEquivalentTo(2))
1725-
// resProfile = res2["profile"].(map[interface{}]interface{})
1726-
// iterProfile0 = resProfile["Iterators profile"].([]interface{})[0].(map[interface{}]interface{})
1727-
// Expect(iterProfile0["Counter"]).To(BeEquivalentTo(2))
1728-
// Expect(iterProfile0["Type"]).To(BeEquivalentTo("WILDCARD"))
1729-
// })
1730-
1731-
// It("should FTProfile Search Limited", Label("search", "ftprofile"), func() {
1732-
// val, err := client.FTCreate(ctx, "idx1", &redis.FTCreateOptions{}, &redis.FieldSchema{FieldName: "t", FieldType: redis.SearchFieldTypeText}).Result()
1733-
// Expect(err).NotTo(HaveOccurred())
1734-
// Expect(val).To(BeEquivalentTo("OK"))
1735-
// WaitForIndexing(client, "idx1")
1736-
1737-
// client.HSet(ctx, "1", "t", "hello")
1738-
// client.HSet(ctx, "2", "t", "hell")
1739-
// client.HSet(ctx, "3", "t", "help")
1740-
// client.HSet(ctx, "4", "t", "helowa")
1741-
1742-
// // FTProfile Search
1743-
// query := redis.FTSearchQuery("%hell% hel*", &redis.FTSearchOptions{})
1744-
// res1, err := client.FTProfile(ctx, "idx1", true, query).Result()
1745-
// Expect(err).NotTo(HaveOccurred())
1746-
// resProfile := res1["profile"].(map[interface{}]interface{})
1747-
// iterProfile0 := resProfile["Iterators profile"].([]interface{})[0].(map[interface{}]interface{})
1748-
// Expect(iterProfile0["Type"]).To(BeEquivalentTo("INTERSECT"))
1749-
// Expect(len(res1["results"].([]interface{}))).To(BeEquivalentTo(3))
1750-
// Expect(iterProfile0["Child iterators"].([]interface{})[0].(map[interface{}]interface{})["Child iterators"]).To(BeEquivalentTo("The number of iterators in the union is 3"))
1751-
// Expect(iterProfile0["Child iterators"].([]interface{})[1].(map[interface{}]interface{})["Child iterators"]).To(BeEquivalentTo("The number of iterators in the union is 4"))
1752-
// })
1753-
1754-
// It("should FTProfile Search query params", Label("search", "ftprofile"), func() {
1755-
// hnswOptions := &redis.FTHNSWOptions{Type: "FLOAT32", Dim: 2, DistanceMetric: "L2"}
1756-
// val, err := client.FTCreate(ctx, "idx1",
1757-
// &redis.FTCreateOptions{},
1758-
// &redis.FieldSchema{FieldName: "v", FieldType: redis.SearchFieldTypeVector, VectorArgs: &redis.FTVectorArgs{HNSWOptions: hnswOptions}}).Result()
1759-
// Expect(err).NotTo(HaveOccurred())
1760-
// Expect(val).To(BeEquivalentTo("OK"))
1761-
// WaitForIndexing(client, "idx1")
1762-
1763-
// client.HSet(ctx, "a", "v", "aaaaaaaa")
1764-
// client.HSet(ctx, "b", "v", "aaaabaaa")
1765-
// client.HSet(ctx, "c", "v", "aaaaabaa")
1766-
1767-
// // FTProfile Search
1768-
// searchOptions := &redis.FTSearchOptions{
1769-
// Return: []redis.FTSearchReturn{{FieldName: "__v_score"}},
1770-
// SortBy: []redis.FTSearchSortBy{{FieldName: "__v_score", Asc: true}},
1771-
// DialectVersion: 2,
1772-
// Params: map[string]interface{}{"vec": "aaaaaaaa"},
1773-
// }
1774-
// query := redis.FTSearchQuery("*=>[KNN 2 @v $vec]", searchOptions)
1775-
// res1, err := client.FTProfile(ctx, "idx1", false, query).Result()
1776-
// Expect(err).NotTo(HaveOccurred())
1777-
// resProfile := res1["profile"].(map[interface{}]interface{})
1778-
// iterProfile0 := resProfile["Iterators profile"].([]interface{})[0].(map[interface{}]interface{})
1779-
// Expect(iterProfile0["Counter"]).To(BeEquivalentTo(2))
1780-
// Expect(iterProfile0["Type"]).To(BeEquivalentTo(redis.SearchFieldTypeVector.String()))
1781-
// Expect(res1["total_results"]).To(BeEquivalentTo(2))
1782-
// results0 := res1["results"].([]interface{})[0].(map[interface{}]interface{})
1783-
// Expect(results0["id"]).To(BeEquivalentTo("a"))
1784-
// Expect(results0["extra_attributes"].(map[interface{}]interface{})["__v_score"]).To(BeEquivalentTo("0"))
1785-
// })
1786-
17871697
var _ = Describe("RediSearch FT.Config with Resp2 and Resp3", Label("search", "NonRedisEnterprise"), func() {
17881698

17891699
var clientResp2 *redis.Client

0 commit comments

Comments
 (0)