from whoosh import index from whoosh.qparser import MultifieldParser from whoosh import qparser acronym_regex = r"([A-Z][\w,’‘']+(?:(?:\s|&|and|or|the|of|to|in|on|at|for|an|-)+[A-Z][\w,’‘']+){1,})\s\(([A-Za-z\s]+)\)" def search(query,index_dir): ix = index.open_dir(index_dir) mparser = MultifieldParser(["title", "content","date","acronyms"], schema=ix.schema,group=qparser.OrGroup) q = mparser.parse(query) s = ix.searcher() print(q) results = s.search(q, limit=10) for r in results: print(r['title'],r['file_name']) return(list(results))