RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Fix chunks search with keywords not working (#19772)
Wang Qi683a86add702
diff --git a/internal/service/chunk/chunk.go b/internal/service/chunk/chunk.goindex 6c06971728..f9dcc4cef1 100644--- a/internal/service/chunk/chunk.go+++ b/internal/service/chunk/chunk.go@@ -855,10 +855,13 @@ func (s *ChunkService) List(ctx context.Context, req *service.ListChunksRequest,Asc("top_int").Desc("create_timestamp_flt")} else {- matchExprs = append(matchExprs, &types.MatchTextExpr{- MatchingText: keywords,- TopN: size,- })+ queryBuilder := nlp.GetQueryBuilder()+ if queryBuilder == nil {+ queryBuilder = nlp.NewQueryBuilder()+ }+ if matchText, _ := queryBuilder.Question(keywords, "", 0.3); matchText != nil {+ matchExprs = append(matchExprs, matchText)+ }}// Build search request - same as retrieval test but filtered by doc_iddiff --git a/internal/service/chunk/chunk_test.go b/internal/service/chunk/chunk_test.goindex 79f85bdc13..8a7018332f 100644--- a/internal/service/chunk/chunk_test.go+++ b/internal/service/chunk/chunk_test.go@@ -422,11 +422,17 @@ func TestListBuildsMatchTextExprForKeywords(t *testing.T) {if !ok {t.Fatalf("MatchExprs[0] = %T, want *types.MatchTextExpr", engine.searchReq.MatchExprs[0])}- if matchText.MatchingText != "invoice terms" {- t.Fatalf("MatchingText = %q, want %q", matchText.MatchingText, "invoice terms")+ if matchText.MatchingText == "invoice terms" || !strings.Contains(matchText.MatchingText, "invoice") || !strings.Contains(matchText.MatchingText, "terms") {+ t.Fatalf("MatchingText = %q, want a tokenized query containing invoice and terms", matchText.MatchingText)}- if matchText.TopN != size {- t.Fatalf("TopN = %d, want %d", matchText.TopN, size)+ if matchText.TopN != 100 {+ t.Fatalf("TopN = %d, want 100", matchText.TopN)+ }+ if got := matchText.ExtraOptions["original_query"]; got != "invoice terms" {+ t.Fatalf("original_query = %#v, want %q", got, "invoice terms")+ }+ if got := matchText.ExtraOptions["minimum_should_match"]; got != 0.3 {+ t.Fatalf("minimum_should_match = %#v, want 0.3", got)}}