Commits

Matt Chaput committed f77aa15

Added unit test related to issue #266.

Comments (0)

Files changed (1)

tests/test_fields.py

 
     with ix.searcher() as s:
         qp = qparser.QueryParser("b", ix.schema)
+
         def check(qs, nums):
             q = qp.parse(qs)
             r = s.search(q, limit=None)
         check("True", trues)
         check("false", falses)
         check("False", falses)
+        check("t", trues)
+        check("f", falses)
+
+
+def test_boolean_find_deleted():
+    # "Random" string of ones and zeros representing deleted and undeleted
+    domain = "1110001010001110010101000101001011101010001011111101000101010101"
+
+    schema = fields.Schema(i=fields.STORED, b=fields.BOOLEAN(stored=True))
+    ix = RamStorage().create_index(schema)
+    count = 0
+    # Create multiple segments just in case
+    for _ in xrange(5):
+        w = ix.writer()
+        for c in domain:
+            w.add_document(i=count, b=(c == "1"))
+        w.commit(merge=False)
+
+    # Delete documents where "b" is True
+    with ix.writer() as w:
+        w.delete_by_term("b", "t")
+
+    with ix.searcher() as s:
+        # Double check that documents with b=True are all deleted
+        reader = s.reader()
+        for docnum in xrange(s.doc_count_all()):
+            b = s.stored_fields(docnum)["b"]
+            assert_equal(b, reader.is_deleted(docnum))
+
+        # Try doing a search for documents where b=True
+        qp = qparser.QueryParser("b", ix.schema)
+        q = qp.parse("b:t")
+        r = s.search(q)
+        assert_equal(len(r), 0)
 
 
 def test_missing_field():
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.