Matt Chaput avatar Matt Chaput committed a87649f

Simple unit test.

Comments (0)

Files changed (1)

tests/test_results.py

         page.results.formatter = highlight.UppercaseFormatter()
         hi = page[0].highlights("text")
         assert hi == u("ALFA bravo charlie delta echo foxtrot")
+
+
+def test_phrase_keywords():
+    schema = fields.Schema(text=fields.TEXT(stored=True))
+    ix = RamStorage().create_index(schema)
+    with ix.writer() as w:
+        w.add_document(text=u("alfa bravo charlie delta"))
+        w.add_document(text=u("bravo charlie delta echo"))
+        w.add_document(text=u("charlie delta echo foxtrot"))
+        w.add_document(text=u("delta echo foxtrot alfa"))
+        w.add_document(text=u("echo foxtrot alfa bravo"))
+
+    with ix.searcher() as s:
+        q = query.Phrase("text", u("alfa bravo").split())
+        r = s.search(q)
+        assert len(r) == 2
+        kts = " ".join(t for t, score in r.key_terms("text"))
+        assert kts == "alfa bravo charlie foxtrot delta"
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.