Skip to content

Commit 8cb33da

Browse files
committed
add stemming and OrGrouping
1 parent a08c578 commit 8cb33da

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
import json
44
from whoosh.index import create_in, open_dir
55
from whoosh.fields import *
6-
from whoosh.qparser import QueryParser
6+
from whoosh.qparser import QueryParser, OrGroup
7+
from whoosh.analysis import StemmingAnalyzer
8+
from glob import glob
79

810

9-
schema = Schema(path=ID(stored=True), content=TEXT)
11+
schema = Schema(path=ID(stored=True), content=TEXT(StemmingAnalyzer()))
1012
INDEX_DIR = "whoosh_index"
1113

1214
def read_text_from_pdf(path):
@@ -47,7 +49,7 @@ def __init__(self, path, content) -> None:
4749

4850
def search_by_term(INDEX_DIR, term):
4951
ix = get_whoosh_ix(INDEX_DIR)
50-
qp = QueryParser("content", schema=ix.schema)
52+
qp = QueryParser("content", schema=ix.schema, group=OrGroup)
5153
q = qp.parse(term)
5254
search_results = []
5355
with ix.searcher() as searcher:

0 commit comments

Comments
 (0)