{1}
>>> c.query('*')
{1, 2, 3}
+ >>> c.query('*:*')
+ {1, 2, 3}
"""
def __init__(self) -> None:
def get_docids_by_exact_tag(self, tag: str) -> Set[str]:
"""Return the set of docids that have a particular tag."""
-
return self.docids_by_tag[tag]
def get_docids_by_searching_tags(self, tag: str) -> Set[str]:
tag1 and key:*
"""
- if query == '*':
- return set(self.documents_by_docid.keys())
try:
root = self._parse_query(query)
except ParseError as e:
key, value = tag.split(":")
except ValueError as v:
raise ParseError(f'Invalid key:value syntax at "{tag}"') from v
- if value == "*":
- r = self.corpus.get_docids_with_property(key)
+ if key == '*':
+ r = set()
+ for s in self.corpus.docids_by_tag.values():
+ r.update(s)
else:
- r = self.corpus.get_docids_by_property(key, value)
+ if value == '*':
+ r = self.corpus.get_docids_with_property(key)
+ else:
+ r = self.corpus.get_docids_by_property(key, value)
else:
- r = self.corpus.get_docids_by_exact_tag(tag)
+ if tag == '*':
+ r = set()
+ for s in self.corpus.docids_by_tag.values():
+ r.update(s)
+ else:
+ r = self.corpus.get_docids_by_exact_tag(tag)
retval.update(r)
else:
raise ParseError(f"Unexpected query {tag}")