Skip to content

Commit

Permalink
Fields/highlighting would only apply to "size" number of docs
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinavdangeti committed Feb 8, 2021
1 parent c870b73 commit 36861dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions search.go
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,11 @@ func MemoryNeededForSearchResult(req *SearchRequest) uint64 {
// overhead from fields, highlighting
var d document.Document
if len(req.Fields) > 0 || req.Highlight != nil {
for i := 0; i < numDocMatches; i++ {
estimate += d.Size()
numDocsApplicable := req.Size
if numDocsApplicable > collector.PreAllocSizeSkipCap {
numDocsApplicable = collector.PreAllocSizeSkipCap
}
estimate += numDocsApplicable * d.Size()
}

return uint64(estimate)
Expand Down

0 comments on commit 36861dd

Please sign in to comment.