fix: search mount point inclusion
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user