From c6bf262f94bede8fb594123af84be7781b140e38 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期五, 24 十一月 2023 17:03:33 +0800 Subject: [PATCH] fix --- pkg/blevex/bleve.go | 9 +++------ service/input_history_search.go | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pkg/blevex/bleve.go b/pkg/blevex/bleve.go index fcf587b..08fe999 100644 --- a/pkg/blevex/bleve.go +++ b/pkg/blevex/bleve.go @@ -69,7 +69,7 @@ if err != nil { return } - req := bleve.NewSearchRequest(bleve.NewQueryStringQuery(keyword)) + req := bleve.NewSearchRequest(bleve.NewMatchQuery(keyword)) req.From = from req.Size = size res, err := index.Search(req) @@ -93,11 +93,8 @@ // Create a boolean query with a should clause for fuzzy search boolQuery := bleve.NewBooleanQuery() - - fuzzyQuery := bleve.NewFuzzyQuery(keyword) - fuzzyQuery.SetFuzziness(2) // Set the fuzziness level as needed - - boolQuery.AddShould(fuzzyQuery) + fuzzyQuery := bleve.NewMatchQuery(keyword) + boolQuery.AddMust(fuzzyQuery) // Add a must clause for category filtering for key, val := range conditions { diff --git a/service/input_history_search.go b/service/input_history_search.go index 19bfa46..c3aca77 100644 --- a/service/input_history_search.go +++ b/service/input_history_search.go @@ -62,7 +62,7 @@ func SearchHistoryReport(keyword string, operationType constvar.BaseOperationType, page, pageSize int) (recordIds []int, total uint64, err error) { var ids []string from := (page - 1) * pageSize - ids, total, err = blevex.Search(HistoryReportIndexName, keyword, from, pageSize) + ids, total, err = blevex.ComplexSearch(HistoryReportIndexName, keyword, map[string]interface{}{"baseOperationType": operationType}, from, pageSize) if err != nil { return } -- Gitblit v1.8.0