Improve wildcard semantics again.
authorScott Gasch <[email protected]>
Mon, 18 Apr 2022 18:21:24 +0000 (11:21 -0700)
committerScott Gasch <[email protected]>
Mon, 18 Apr 2022 18:21:24 +0000 (11:21 -0700)
logical_search.py

index 0cfbc8d22624bffe9bc227e3ffde0abc0f313053..2f79db09d83dbe0b14e2ab6323e107f31384e148 100644 (file)
@@ -108,6 +108,8 @@ class Corpus(object):
     {1, 2, 3}
     >>> c.query('*:*')
     {1, 2, 3}
+    >>> c.query('*:Scott')
+    {1, 3}
     """
 
     def __init__(self) -> None:
@@ -360,10 +362,12 @@ class Node(object):
                             key, value = tag.split(":")
                         except ValueError as v:
                             raise ParseError(f'Invalid key:value syntax at "{tag}"') from v
+
                         if key == '*':
                             r = set()
-                            for s in self.corpus.docids_by_tag.values():
-                                r.update(s)
+                            for kv, s in self.corpus.docids_by_property.items():
+                                if value in ('*', kv[1]):
+                                    r.update(s)
                         else:
                             if value == '*':
                                 r = self.corpus.get_docids_with_property(key)