whoosh-community / whoosh

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

Fix 480: GtLtPlugin recurse GroupNodes #536

Closed stevennic closed 5 years ago

stevennic commented 5 years ago

Resolve bug #480.

This happens with numeric ranges in parentheses. The root cause was an omission in plugins.py:GtLtPlugin. During the filterize() function in qparser/default.py:329, the nodes are run through all registered plugins in sequence. In the GtLtPlugin (qparser/plugins.py), the main method do_gtlt converts GtLtNode nodes to RangeNode nodes but omitted to recurse down its subnodes to do the same. As a result, ranges inside a parenthesis were being ignored, leaving the ranges in their raw, unprocessed form. The nodes coming out of the filterize() function should never have a GtLtNode because they don't have a query() method. Thus the OP's scenario raises a NotImplementedError exception.

The solution properly recurses through the nodes and yields a fully processed query node tree.

codecov[bot] commented 5 years ago

Codecov Report

Merging #536 into master will increase coverage by 0.03%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #536      +/-   ##
=========================================
+ Coverage   82.97%     83%   +0.03%     
=========================================
  Files         132     132              
  Lines       29602   29610       +8     
=========================================
+ Hits        24562   24578      +16     
+ Misses       5040    5032       -8
Impacted Files Coverage Δ
tests/test_parsing.py 100% <100%> (ø) :arrow_up:
src/whoosh/qparser/plugins.py 95.73% <100%> (+0.47%) :arrow_up:
src/whoosh/index.py 76.01% <0%> (+1.55%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a8a15c4...1f6865c. Read the comment docs.

nijel commented 5 years ago

Merged, thanks for your contribution!