fix: search mount point inclusion

This commit is contained in:
Florian Schade
2023-09-01 12:07:38 +02:00
committed by jkoberg
parent b7f42004bc
commit af9556f8f1
+10 -3
View File
@@ -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
}