@@ -68,7 +68,7 @@ func NewNestedConjunctionSearcher(ctx context.Context, indexReader index.IndexRe
6868 return & rv , nil
6969}
7070
71- func (s * NestedConjunctionSearcher ) initSearchers (ctx * search.SearchContext ) error {
71+ func (s * NestedConjunctionSearcher ) initSearchers (ctx * search.SearchContext ) ( bool , error ) {
7272 var err error
7373 // get all searchers pointing at their first match
7474 for i , searcher := range s .searchers {
@@ -77,16 +77,16 @@ func (s *NestedConjunctionSearcher) initSearchers(ctx *search.SearchContext) err
7777 }
7878 s .currs [i ], err = searcher .Next (ctx )
7979 if err != nil {
80- return err
80+ return false , err
8181 }
8282 if s .currs [i ] == nil {
8383 // one of the searchers is exhausted, so we are done
84- return nil
84+ return true , nil
8585 }
8686 // get the ancestry chain for this match
8787 s .currAncestors [i ], err = s .nestedReader .Ancestors (s .currs [i ].IndexInternalID )
8888 if err != nil {
89- return err
89+ return false , err
9090 }
9191 }
9292 // scan the ancestry chains for all searchers to get the pivotIDx
@@ -107,7 +107,7 @@ func (s *NestedConjunctionSearcher) initSearchers(ctx *search.SearchContext) err
107107 }
108108 }
109109 s .initialized = true
110- return nil
110+ return false , nil
111111}
112112
113113func (s * NestedConjunctionSearcher ) computeQueryNorm () {
@@ -188,10 +188,13 @@ func (s *NestedConjunctionSearcher) DocumentMatchPoolSize() int {
188188
189189func (s * NestedConjunctionSearcher ) Next (ctx * search.SearchContext ) (* search.DocumentMatch , error ) {
190190 if ! s .initialized {
191- err := s .initSearchers (ctx )
191+ exhausted , err := s .initSearchers (ctx )
192192 if err != nil {
193193 return nil , err
194194 }
195+ if exhausted {
196+ return nil , nil
197+ }
195198 }
196199 // we have the pivot searcher, now try to align all the others to it, using the racecar algorithm,
197200 // basically - the idea is simple - we first check if the pivot searcher's indexInternalID
0 commit comments