I would like to know, how to use proximity search with the whoosh. I have read the documentation of the whoosh. It was written in the document that by using class whoosh.query.Phrase(fieldname, words, slop=1, boost=1.0, char_ranges=None)
once can able to use the proximity search.
for example, I need to find "Hello World" in the index, but "Hello" should have 5-word distance from the word "World".
As of now, I am using the following code and its working fine with the normal parser.
from whoosh.query import *
from whoosh import qparser
index_path = "/home/abhi/Desktop/CLIR/indexdir_test"
ix = open_dir(index_path)
query='Hello World'
ana = StandardAnalyzer(stoplist=stop_word)
qp = QueryParser("content", schema=ix.schema,termclass=Phrase)
q=qp.parse(query)
with ix.searcher() as s:
results = s.search(qp,limit=5)
for result in results:
print(result['content']+result['title'])
print (result.score)
print(len(results))
Guys, please help me how to use the class whoosh.query.Phrase(fieldname, words, slop=1, boost=1.0, char_ranges=None)' to use the proximity search and varies the distance between the words. Thanks in Advance