From af9556f8f19e54f5d5a255db08e9b1d57167a921 Mon Sep 17 00:00:00 2001 From: Florian Schade Date: Fri, 1 Sep 2023 09:01:01 +0200 Subject: [PATCH] fix: search mount point inclusion --- services/search/pkg/engine/bleve.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/services/search/pkg/engine/bleve.go b/services/search/pkg/engine/bleve.go index 4f25dfa02..58d29036b 100644 --- a/services/search/pkg/engine/bleve.go +++ b/services/search/pkg/engine/bleve.go @@ -170,10 +170,17 @@ func (b *Bleve) Search(_ context.Context, sir *searchService.SearchIndexRequest) matches := make([]*searchMessage.Match, 0, len(res.Hits)) totalMatches := res.Total for _, hit := range res.Hits { + if sir.Ref != nil && !strings.HasPrefix(getFieldValue[string](hit.Fields, "Path"), utils.MakeRelativePath(path.Join(sir.Ref.Path, "/"))) { + totalMatches-- + continue + } + if sir.Ref != nil { - path := strings.TrimSuffix(getFieldValue[string](hit.Fields, "Path"), "/") - relRefPath := utils.MakeRelativePath(sir.Ref.Path) - if relRefPath != "." && !strings.HasPrefix(path, relRefPath+"/") { + hitPath := strings.TrimSuffix(getFieldValue[string](hit.Fields, "Path"), "/") + sirPath := utils.MakeRelativePath(sir.Ref.Path) + isMountPoint := hitPath == sirPath + + if !isMountPoint && sirPath != "." && !strings.HasPrefix(hitPath, sirPath+"/") { totalMatches-- continue }