1. Matt Chaput
  2. whoosh

Commits

Matt Chaput  committed a86e744

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

  • Participants
  • Parent commits 5a239c5
  • Branches default

Comments (0)

Files changed (2)

File src/whoosh/sorting.py

View file
  • Ignore whitespace
         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:

File tests/test_sorting.py

View file
  • Ignore whitespace
         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