Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix: exclude compiled artifacts from chunk lists (#18382)

buua436f5efff8d6d5e
diff --git a/internal/service/chunk/chunk.go b/internal/service/chunk/chunk.go
index d18560e463..23a34f8f39 100644
--- a/internal/service/chunk/chunk.go
+++ b/internal/service/chunk/chunk.go
@@ -882,7 +882,8 @@ func (s *ChunkService) List(ctx context.Context, req *service.ListChunksRequest,
"available_int",
},
Filter: map[string]interface{}{
- "doc_id": req.DocID,
+ "doc_id": req.DocID,
+ "must_not": map[string]interface{}{"exists": "compile_kwd"},
},
}
diff --git a/internal/service/chunk/chunk_test.go b/internal/service/chunk/chunk_test.go
index 0bd56765ee..27ddf47e7a 100644
--- a/internal/service/chunk/chunk_test.go
+++ b/internal/service/chunk/chunk_test.go
@@ -405,6 +405,10 @@ func TestListBuildsMatchTextExprForKeywords(t *testing.T) {
if got := engine.searchReq.Filter["doc_id"]; got != documentID {
t.Fatalf("doc_id filter = %#v, want %q", got, documentID)
}
+ mustNot, ok := engine.searchReq.Filter["must_not"].(map[string]interface{})
+ if !ok || mustNot["exists"] != "compile_kwd" {
+ t.Fatalf("must_not filter = %#v, want compile_kwd existence exclusion", engine.searchReq.Filter["must_not"])
+ }
if slices.Contains(engine.searchReq.SelectFields, "content") {
t.Fatalf("SelectFields = %#v, should not request content with content_with_weight", engine.searchReq.SelectFields)
}