From 001b734eb651c819d880df1017829bd54d7c16f7 Mon Sep 17 00:00:00 2001 From: Scott Gasch Date: Mon, 18 Apr 2022 11:21:24 -0700 Subject: [PATCH] Improve wildcard semantics again. --- logical_search.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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) -- 2.47.1