def get_num_items(self): """ Get the number of indexed items. """ search_index = SearchIndex() print "Number of indexed items: %s" % search_index.index_obj.doc_count() search_index.close()
def dummy_search_index(): search_index = SearchIndex( index_path="test", log=Logging(log_file_name="test.log"), ) search_index.add( content_id=u'1', content=u'Testing ABC', ) search_index.add( content_id=u'2', content=u'Testing DEF', ) return search_index
def get_search_speed(self): """ Get the average speed at which searches are performed over a predefined list of random keywords. """ search_index = SearchIndex() result_time = [] for q in ['dog', 'cat', 'website', 'news', 'social']: start_time = time.clock() results = search_index.search(q) end_time = time.clock() result_time.append(end_time - start_time) search_index.close() print "Average search speed: %s secs" % (round(sum(result_time) / len(result_time), 2))