Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Created October 10, 2019 12:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/4919cfb96e5041b92507e8b2935a047b to your computer and use it in GitHub Desktop.
Save GroupDocsGists/4919cfb96e5041b92507e8b2935a047b to your computer and use it in GitHub Desktop.
string indexFolder = @"c:\MyIndex\";
string documentsFolder = @"c:\MyDocuments\";
// Creating an index in the specified folder
Index index = new Index(indexFolder);
// Indexing documents from the specified folder
index.Add(documentsFolder);
// Creating a search options object
SearchOptions options = new SearchOptions();
options.FuzzySearch.Enabled = true; // Enabling the fuzzy search
options.FuzzySearch.FuzzyAlgorithm = new TableDiscreteFunction(2); // Setting the number of possible differences for each word
// Searching in the index
SearchResult result = index.Search("Happiness", options);
if (result.DocumentCount > 0)
{
// Generating HTML-formatted text of a document with highlighted search results
index.Highlight(result.GetFoundDocument(0), new HtmlHighlighter(new FileOutputAdapter(@"c:\Highlighted.html")));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment