fix the total count

This commit is contained in:
Roman Perekhod
2023-07-12 18:13:58 +02:00
parent 1aa114c336
commit 99b8cdc7d6
3 changed files with 102 additions and 19 deletions
+3 -1
View File
@@ -162,8 +162,10 @@ 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
}
@@ -206,7 +208,7 @@ func (b *Bleve) Search(_ context.Context, sir *searchService.SearchIndexRequest)
return &searchService.SearchIndexResponse{
Matches: matches,
TotalMatches: int32(res.Total),
TotalMatches: int32(totalMatches),
}, nil
}