Commits

Matt Chaput committed 7c5bb4a

Changed priority of SequencePlugin filter so it runs before operators.
Previously an operator could capture a QuoteNode before the sequence saw it.

  • Participants
  • Parent commits 1ea83e3

Comments (0)

Files changed (2)

File src/whoosh/qparser/plugins.py

         return [(FnTagger(self.expr, self.QuoteNode, "quote"), 0)]
 
     def filters(self, parser):
-        return [(self.do_quotes, 650)]
+        return [(self.do_quotes, 550)]
 
     def do_quotes(self, parser, group):
         # New group to copy nodes into

File tests/test_parse_plugins.py

     assert q[1].slop == 2
     assert q[1][1].__class__ == query.FuzzyTerm
     assert q[1][1].maxdist == 3
+
+
+def test_sequence_andmaybe():
+    qp = default.QueryParser("f", None)
+    qp.remove_plugin_class(plugins.PhrasePlugin)
+    qp.add_plugins([plugins.FuzzyTermPlugin(), plugins.SequencePlugin()])
+
+    q = qp.parse(u('Dahmen ANDMAYBE "Besov Spaces"'))
+    assert isinstance(q, query.AndMaybe)
+    assert q[0] == query.Term("f", u("Dahmen"))
+    assert q[1] == query.Sequence([query.Term("f", u("Besov")),
+                                   query.Term("f", u("Spaces"))])
+