fix bug of token4-token7 model config complete op
This commit is contained in:
parent
8313b16dfe
commit
c29f58f388
|
|
@ -395,6 +395,32 @@ func handleLevelFuzzySearch(ctx context.Context, rdb *redis.Client, hierarchy co
|
|||
specificalKey = inputSlice[specificalKeyIndex]
|
||||
}
|
||||
|
||||
if recommendLenType == constants.IsLocalRecommendLength && hierarchy == constants.ConfigRecommendHierarchyType {
|
||||
// token4-token7 model and query all config keys
|
||||
redisSetKey = constants.RedisAllCompTagSetKey
|
||||
keyExists, err := rdb.SIsMember(ctx, redisSetKey, specificalKey).Result()
|
||||
if err != nil {
|
||||
logger.Error(ctx, "check key exist from redis set failed ", "key", redisSetKey, "error", err)
|
||||
fanInChan <- SearchResult{
|
||||
RecommendType: hierarchy,
|
||||
QueryDatas: nil,
|
||||
IsFuzzy: false,
|
||||
Err: err,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if !keyExists {
|
||||
fanInChan <- SearchResult{
|
||||
RecommendType: hierarchy,
|
||||
QueryDatas: []string{},
|
||||
IsFuzzy: false,
|
||||
Err: nil,
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
members, err := queryMemberFromSpecificsLevel(ctx, rdb, hierarchy, specificalKey)
|
||||
if err != nil && err != redis.Nil {
|
||||
logger.Error(ctx, "query members from redis by special key failed", "key", specificalKey, "member", searchInput, "op", "SMember", "error", err)
|
||||
|
|
@ -459,6 +485,10 @@ func handleLevelFuzzySearch(ctx context.Context, rdb *redis.Client, hierarchy co
|
|||
return
|
||||
}
|
||||
|
||||
if hierarchy == constants.MeasTagRecommendHierarchyType || hierarchy == constants.ConfigRecommendHierarchyType {
|
||||
fmt.Printf("fuzzy origin recommneds:%v\n", recommends)
|
||||
}
|
||||
|
||||
if len(recommends) == 0 {
|
||||
logger.Info(ctx, "fuzzy search without result", "hierarchy", hierarchy, "search_input", searchInput, "error", err)
|
||||
}
|
||||
|
|
@ -489,8 +519,10 @@ func runFuzzySearch(ctx context.Context, searchInput string, searchPrefix string
|
|||
configToken = searchPrefix[lastDotIndex+1:]
|
||||
comparePrefix = searchPrefix[:lastDotIndex]
|
||||
}
|
||||
|
||||
fmt.Printf("run fuzzy search, original searchPrefix:%s\n", searchPrefix)
|
||||
fmt.Printf("run fuzzy search, original comparePrefix:%s\n", comparePrefix)
|
||||
}
|
||||
|
||||
for searchInputLen != 0 {
|
||||
fuzzyInput := strings.Join([]string{comparePrefix, searchInput}, ".")
|
||||
results, err := ac.SuggestOpts(fuzzyInput, redisearch.SuggestOptions{
|
||||
|
|
@ -511,6 +543,8 @@ func runFuzzySearch(ctx context.Context, searchInput string, searchPrefix string
|
|||
searchInputLen = len(searchInput)
|
||||
continue
|
||||
}
|
||||
fmt.Printf("len of fuzzy search results:%d\n", len(results))
|
||||
fmt.Printf("fuzzy search results:%v\n", results)
|
||||
|
||||
var recommends []string
|
||||
for _, result := range results {
|
||||
|
|
@ -534,14 +568,23 @@ func runFuzzySearch(ctx context.Context, searchInput string, searchPrefix string
|
|||
termHierarchyLen = strings.Count(result.Term, ".") + 1
|
||||
}
|
||||
|
||||
fmt.Printf("termHierarchyLen:%d\n", termHierarchyLen)
|
||||
fmt.Printf("compareHierarchy:%d\n", compareHierarchyLen)
|
||||
fmt.Printf("termPrefix:%s\n", termPrefix)
|
||||
fmt.Printf("comparePrefix:%s\n", comparePrefix)
|
||||
if termHierarchyLen == compareHierarchyLen && termPrefix == comparePrefix && strings.HasPrefix(termLastPart, searchInput) {
|
||||
recommend := result.Term
|
||||
if hierarchy == constants.MeasTagRecommendHierarchyType {
|
||||
recommend = strings.Join([]string{termPrefix, configToken, termLastPart}, ".")
|
||||
}
|
||||
|
||||
fmt.Printf("process recommend:%s\n", recommend)
|
||||
recommends = append(recommends, recommend)
|
||||
}
|
||||
}
|
||||
fmt.Println("--------------")
|
||||
fmt.Printf("recommends:%v\n", recommends)
|
||||
fmt.Printf("len of recommends:%d\n", len(recommends))
|
||||
return recommends, nil
|
||||
}
|
||||
return []string{}, nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue