Each time you perform a search in an index, a report is generated for that search. An array of search reports can be obtained by calling the GetSearchReports 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 MaxSearchReportCount 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 ToString 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.
C#
stringindexFolder=@"c:\MyIndex\";stringdocumentsFolder=@"c:\MyDocuments\";// Creating an index in the specified folderIndexindex=newIndex(indexFolder);// Indexing documents from the specified folderindex.Add(documentsFolder);// Searching in indexSearchResultresult1=index.Search("Einstein");SearchResultresult2=index.Search("\"Theory of Relativity\"");// Getting search reportsSearchReport[]reports=index.GetSearchReports();// Printing reports to the consoleforeach(SearchReportreportinreports){Console.WriteLine("Query: "+report.ToString());Console.WriteLine("Time: "+report.StartTime);Console.WriteLine("Duration: "+report.SearchDuration);Console.WriteLine("Documents: "+report.DocumentCount);Console.WriteLine("Occurrences: "+report.OccurrenceCount);Console.WriteLine();}
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: