def search(term): startTiming() searcher = IndexSearcher(g_indexPath) # Note that all queries have to be submitted in lower-case... q = termSearch(term) runQuery(q, searcher) #q = phraseSearch('fox and the crow') #runQuery(q, searcher) # A boolean search equiv to 'x and not y' #q = boolSearch(['fox'], [], ['crow', 'lion']) #runQuery(q, searcher) # Search the title field #q = titleSearch('frog') #runQuery(q, searcher) searcher.close() endTiming() dumpTiming()
if __name__ == "__main__": """One shot search. Opens and closes the index on every query. """ import time tt = time.time() searcher = IndexSearcher('aesopind') # Note that all queries have to be submitted in lower-case... q = termSearch('fox') runQuery(q, searcher) q = phraseSearch('fox and the crow') runQuery(q, searcher) # A boolean search equiv to 'x and not y' q = boolSearch(['fox'], [], ['crow', 'lion']) runQuery(q, searcher) # Search the title field q = titleSearch('frog') runQuery(q, searcher) searcher.close() print time.time() - tt