SearchResult Class |
Namespace: GroupDocs.Search.Results
The SearchResult type exposes the following members.
Name | Description | |
---|---|---|
![]() | DocumentCount |
Gets the number of documents found.
|
![]() | EndTime |
Gets the end time of the search.
|
![]() | NextChunkSearchToken |
Gets a chunk search token for searching the next chunk.
|
![]() | OccurrenceCount |
Gets the total number of occurrences found.
|
![]() | SearchDuration |
Gets the search duration.
|
![]() | StartTime |
Gets the start time of the search.
|
![]() | Truncated |
Gets a value indicating that the result is truncated.
|
![]() | Warnings |
Gets a warnings describing the result.
|
Name | Description | |
---|---|---|
![]() | Equals | (Inherited from Object.) |
![]() | Finalize | (Inherited from Object.) |
![]() | GetEnumerator |
Returns an enumerator that iterates through the collection of the documents found.
|
![]() | GetFoundDocument |
Gets the found document by index.
|
![]() | GetHashCode | (Inherited from Object.) |
![]() | GetType | (Inherited from Object.) |
![]() | MemberwiseClone | (Inherited from Object.) |
![]() | ToString | (Inherited from Object.) |
string indexFolder = @"c:\MyIndex\"; string documentFolder = @"c:\MyDocuments\"; // Creating an index Index index = new Index(indexFolder); // Indexing documents from the specified folder index.Add(documentFolder); // Setting search options SearchOptions options = new SearchOptions(); options.FuzzySearch.Enabled = true; // Enabling the fuzzy search options.FuzzySearch.FuzzyAlgorithm = new TableDiscreteFunction(3); // Setting the maximum number of differences to 3 // Search for documents containing the word 'Einstein' or the phrase 'Theory of Relativity' SearchResult result = index.Search("Einstein OR \"Theory of Relativity\"", options); // Printing the result Console.WriteLine("Documents: " + result.DocumentCount); Console.WriteLine("Total occurrences: " + result.OccurrenceCount); for (int i = 0; i < result.DocumentCount; i++) { FoundDocument document = result.GetFoundDocument(i); Console.WriteLine("\tDocument: " + document.DocumentInfo.FilePath); Console.WriteLine("\tOccurrences: " + document.OccurrenceCount); for (int j = 0; j < document.FoundFields.Length; j++) { FoundDocumentField field = document.FoundFields[j]; Console.WriteLine("\t\tField: " + field.FieldName); Console.WriteLine("\t\tOccurrences: " + document.OccurrenceCount); // Printing found terms if (field.Terms != null) { for (int k = 0; k < field.Terms.Length; k++) { Console.WriteLine("\t\t\t" + field.Terms[k].PadRight(20) + field.TermsOccurrences[k]); } } // Printing found phrases if (field.TermSequences != null) { for (int k = 0; k < field.TermSequences.Length; k++) { string sequence = string.Join(" ", field.TermSequences[k]); Console.WriteLine("\t\t\t" + sequence.PadRight(30) + field.TermSequencesOccurrences[k]); } } } }