Managing dictionaries in network

To obtain a dictionary from a shard of a search network node, use the GetDictionary method of the Indexer class. The first parameter of the GetDictionary method is the type of the required dictionary, and the second parameter is the index of the shard in the network. The method returns an object of type DictionaryBase, which must be cast to the required dictionary type. In the Indexer class there are also methods that immediately return the desired dictionary type without casting the type and without specifying the type in the parameters.

You can then perform all operations on the dictionary object that are valid for a dictionary in a single index. For information about working with dictionaries, see articles Managing Dictionaries.

And after setting up the dictionary, you need to return the dictionary object back to the shard using the SetDictionary method of the Indexer class, specifying the index of the desired shard. Alternatively, you can set the dictionary object to all shards by the SetDictionary method with one parameter without specifying the shard index.

The following code example demonstrates working with dictionaries on the search network.

C#

Console.WriteLine("Adding synonyms");

Indexer indexer = node.Indexer;

int[] indices = node.GetShardIndices();
SynonymDictionary dictionary = indexer.GetSynonymDictionary(indices[0]);

if (clearBeforeAdding)
{
    dictionary.Clear();
}
dictionary.AddRange(new string[][] { group });

indexer.SetDictionary(dictionary);

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.