Skip to content

Commit

Permalink
Merge pull request #11 from maksimstojkovic/main
Browse files Browse the repository at this point in the history
Add support for wildcard regex tokenization
  • Loading branch information
ZeroCool940711 authored Jan 3, 2024
2 parents 95b81f8 + 21d803a commit c663c61
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/whoosh/analysis/tokenizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from whoosh.util.text import rcompile


default_pattern = rcompile(r"\w+(\.?\w+)*")
default_pattern = rcompile(r"[\w\*]+(\.?[\w\*]+)*")


# Tokenizers
Expand Down
8 changes: 6 additions & 2 deletions src/whoosh/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,8 +1224,12 @@ def self_parsing(self):
def parse_query(self, fieldname, qstring, boost=1.0):
from whoosh import query

terms = [query.Term(fieldname, g)
for g in self.process_text(qstring, mode='query')]
terms = []
for g in self.process_text(qstring, mode='query'):
if g == "*":
terms.append(query.Wildcard(fieldname, g, boost=boost))
else:
terms.append(query.Term(fieldname, g, boost=boost))
cls = query.Or if self.queryor else query.And

return cls(terms, boost=boost)
Expand Down

0 comments on commit c663c61

Please sign in to comment.