Commits

Matt Chaput committed a86e744

Fixed bug with missing values in field grouped by facet with allow_overlap. Fixes issue #330.

Comments (0)

Files changed (2)

src/whoosh/sorting.py

         elif self._use_column:
             return self._creader[docid]
         else:
-            return self._lists[docid] or None
+            return self._lists[docid] or [None]
 
     def key_for(self, matcher, docid):
         if self._use_vectors:

tests/test_sorting.py

         assert r.groups("tag") == {None: [2, 4], 0: [3], 1: [0, 1]}
 
 
+def test_missing_overlap():
+    schema = fields.Schema(a=fields.NUMERIC(stored=True),
+                           b=fields.KEYWORD(stored=True))
+    ix = RamStorage().create_index(schema)
+    with ix.writer() as w:
+        w.add_document(a=0, b=u("one two"))
+        w.add_document(a=1)
+        w.add_document(a=2, b=u("two three"))
+        w.add_document(a=3)
+        w.add_document(a=4, b=u("three four"))
+
+    with ix.searcher() as s:
+        facet = sorting.FieldFacet("b", allow_overlap=True)
+        r = s.search(query.Every(), groupedby=facet)
+        target = {"one": [0], "two": [0, 2], "three": [2, 4],"four": [4],
+                  None: [1, 3]}
+        assert r.groups() == target
+
+
 def test_date_facet():
     from whoosh import columns
 
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.