From: Scott Gasch Date: Mon, 18 Apr 2022 18:21:24 +0000 (-0700) Subject: Improve wildcard semantics again. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=001b734eb651c819d880df1017829bd54d7c16f7;p=python_utils.git Improve wildcard semantics again. --- diff --git a/logical_search.py b/logical_search.py index 0cfbc8d..2f79db0 100644 --- a/logical_search.py +++ b/logical_search.py @@ -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)