Synonym dictionary

The SynonymDictionary class is designed to store synonyms in an index. For information on searching using synonyms, see the Synonym search page.

To get the number of synonyms in the dictionary, use the Count property.

To add groups of synonyms to the dictionary, use the AddRange method.

The Clear method is used to remove all synonyms from the dictionary.

The GetSynonyms method is used to get a list of synonyms for a given word.

The GetSynonymGroups method is used to get all synonym groups to which a given word belongs.

To get all synonym groups from the dictionary, use the GetAllSynonymGroups method.

To export synonyms to a file, use the ExportDictionary method.

To import synonyms from a file, use the ImportDictionary method.

The following example demonstrates the use of methods of the synonym dictionary.


string indexFolder = @"c:\MyIndex\";

// Creating an index from in specified folder
Index index = new Index(indexFolder);

// Getting synonyms for word 'make'
string[] synonyms = index.Dictionaries.SynonymDictionary.GetSynonyms("make");
Console.WriteLine("Synonyms for 'make':");
for (int i = 0; i < synonyms.Length; i++)

// Getting groups of synonyms to which word 'make' belongs to
string[][] groups = index.Dictionaries.SynonymDictionary.GetSynonymGroups("make");
Console.WriteLine("Synonym groups for 'make':");
for (int i = 0; i < groups.Length; i++)
    string[] group = groups[i];
    for (int j = 0; j < group.Length; j++)
        Console.Write(group[j] + " ");

if (index.Dictionaries.SynonymDictionary.Count > 0)
    // Removing all synonyms from the dictionary

// Adding synonyms to the dictionary
string[][] synonymGroups = new string[][]
    new string[] { "achieve", "accomplish", "attain", "reach" },
    new string[] { "accept", "take", "have" },

// Export synonyms to a file

// Import synonyms from a file

More resources

GitHub examples

You may easily run the code from documentation articles and see the features in action in our GitHub examples:

Free online document search App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to search over your PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX and more with our free online Free Online Document Search App.