fix: failing tests and filter out specific matches

This commit is contained in:
Florian Schade
2023-09-01 12:07:56 +02:00
committed by jkoberg
parent a0f2adedb5
commit 0ec78ee7bb
2 changed files with 13 additions and 7 deletions
+2 -7
View File
@@ -170,17 +170,12 @@ 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 {
hitPath := strings.TrimSuffix(getFieldValue[string](hit.Fields, "Path"), "/")
requestedPath := utils.MakeRelativePath(sir.Ref.Path)
isPathRoot := hitPath == requestedPath
isRoot := hitPath == requestedPath
if !isPathRoot && requestedPath != "." && !strings.HasPrefix(hitPath, requestedPath+"/") {
if !isRoot && requestedPath != "." && !strings.HasPrefix(hitPath, requestedPath+"/") {
totalMatches--
continue
}