Each time you perform a search in an index, a report is generated for that search. A list of search reports can be obtained by calling the get_search_reports method of the Index class. Reports are stored in the index only while the index is loaded into RAM for use. If you reload the index, the reports will not be restored.
You can configure the maximum number of stored reports using the max_search_report_count property of the IndexSettings class. The default value is 10. The value can be changed at any time. Learn more about index settings on the page Search index settings.
Each search report is represented by an instance of the SearchReport class, which contains the following information:
The to_string method returns the search query in text form for both kinds of queries.
The following example demonstrates how to get search reports from an index.
fromgroupdocs.searchimportIndex# Creating an index in the specified folderindex=Index("./index")# Indexing documents from the specified folderindex.add("./documents")# Searching in indexresult1=index.search("Einstein")result2=index.search('"Theory of Relativity"')# Getting search reportsreports=index.get_search_reports()# Printing reports to the consoleforreportinreports:print("Query: "+report.to_string())print("Time: "+str(report.start_time))print("Duration: "+str(report.search_duration))print("Documents: "+str(report.document_count))print("Occurrences: "+str(report.occurrence_count))print()