whoosh-community / whoosh

Whoosh is a fast, featureful full-text indexing and searching library implemented in pure Python.
Other
245 stars 37 forks source link

NestedParent query missing valid result #573

Open hlbnet opened 2 years ago

hlbnet commented 2 years ago

In some circumstances, a NestedParent query does not return what it should (see attached code to reproduce, change file extension to py).

First execute this code as-is. Output: "Found 1 document(s)" is ok. Retry after uncommenting line 35. Output: "Found 0 document(s)" is wrong (should still find 1 document).

Additionnally, you can play with this example. If the content of the line 35 is moved after the line 40, the correct result will be observed again.

Using Whoosh 2.7.4 on Windows 10 with Python 3.10.4.

nestedparentbug.txt

The bug comes if a document matches the 'children' criteria of the NestedParent query. but is itself not in any group, or not in a group matching the 'parent' criteria. This document has no reason be be returned, and is not (good). But, the simple existence of this document makes that the query will not return any next result, even if other documents exists that should be returned by the query.