Matt Chaput avatar 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.

Comments (0)

Files changed (2)

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

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"))])
+
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.