Commits

Matt Chaput committed 9d99ba6

Fixed order of BoostPlugin's filter to run before the OperatorPlugin.
Fixed FunctionPlugin to deal with new ordering.

Comments (0)

Files changed (2)

src/whoosh/qparser/plugins.py

         return node
 
     def filters(self, parser):
-        return [(self.clean_boost, 0), (self.do_boost, 700)]
+        return [(self.clean_boost, 0), (self.do_boost, 510)]
 
     def clean_boost(self, parser, group):
         """This filter finds any BoostNodes in positions where they can't boost
                 and isinstance(group[i + 1], syntax.GroupNode)):
                 nextnode = group[i + 1]
                 node.nodes = list(self.do_functions(parser, nextnode))
+
+                if nextnode.boost != 1:
+                    node.set_boost(nextnode.boost)
+
                 i += 1
             elif isinstance(node, syntax.GroupNode):
                 node = self.do_functions(parser, node)

tests/test_parsing.py

     assert isinstance(q, query.AndMaybe)
     assert q[0] == query.Term("f", u("Dahmen"))
     assert q[1] == query.Phrase("f", [u("Besov"), u("Spaces")])
+
+
+def test_phrase_boost():
+    qp = default.QueryParser("f", None)
+    q = qp.parse(u('Dahmen ANDMAYBE "Besov Spaces"^9'))
+    print(q.__unicode__())
+    assert isinstance(q, query.AndMaybe)
+    assert q[0] == query.Term("f", u("Dahmen"))
+    assert q[1] == query.Phrase("f", [u("Besov"), u("Spaces")], boost=9)
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.