SearchResult Class
Represents a search result matching a search query.
Inheritance Hierarchy

Namespace: GroupDocs.Search.Results
Assembly: GroupDocs.Search (in GroupDocs.Search.dll) Version: 21.8.1
public class SearchResult : IEnumerable<FoundDocument>, 

The SearchResult type exposes the following members.

Public propertyDocumentCount
Gets the number of documents found.
Public propertyEndTime
Gets the end time of the search.
Public propertyNextChunkSearchToken
Gets a chunk search token for searching the next chunk.
Public propertyOccurrenceCount
Gets the total number of occurrences found.
Public propertySearchDuration
Gets the search duration.
Public propertyStartTime
Gets the start time of the search.
Public propertyTruncated
Gets a value indicating that the result is truncated.
Public propertyWarnings
Gets a warnings describing the result.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetEnumerator
Returns an enumerator that iterates through the collection of the documents found.
Public methodGetFoundDocument
Gets the found document by index.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodToString (Inherited from Object.)
The example demonstrates a typical usage of the class.
string indexFolder = @"c:\MyIndex\";
string documentFolder = @"c:\MyDocuments\";

// Creating an index
Index index = new Index(indexFolder);

// Indexing documents from the specified folder

// 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]);
See Also