An instance of the AliasDictionary class contains all the aliases defined in an index. Information on using aliases to search is provided on the Using aliases page.
To get the number of existing aliases, use the Count property.
Use the Add method to add new alias-replacement pair.
Use the AddRange method to add a collection of new alias-replacement pairs.
To remove an alias from the dictionary, use the Remove method.
The Contains method is used to check for the presence of a particular alias in the dictionary.
To get a replacement for a particular alias, use the GetText method.
The Clear method is used to remove all existing aliases from the dictionary.
To export the list of aliases with replacements to a file, use the ExportDictionary method.
To import the list of aliases from a file, use the ImportDictionary method.
The following example demonstrates the use of methods of the alias dictionary.
C#
stringindexFolder=@"c:\MyIndex\";// Creating or opening an index from the specified folderIndexindex=newIndex(indexFolder);if(index.Dictionaries.AliasDictionary.Count>0){// Deleting all existing aliasesindex.Dictionaries.AliasDictionary.Clear();}// Adding aliases to the alias dictionaryindex.Dictionaries.AliasDictionary.Add("t","(theory OR relativity)");index.Dictionaries.AliasDictionary.Add("e","(Einstein OR Albert)");AliasReplacementPair[]pairs=newAliasReplacementPair[]{newAliasReplacementPair("d","daterange(2017-01-01 ~~ 2019-12-31)"),newAliasReplacementPair("n","(100 ~~ 900)"),};index.Dictionaries.AliasDictionary.AddRange(pairs);if(index.Dictionaries.AliasDictionary.Contains("e")){// Getting an alias replacementstringreplacement=index.Dictionaries.AliasDictionary.GetText("e");Console.WriteLine("e - "+replacement);}// Export aliases to a fileindex.Dictionaries.AliasDictionary.ExportDictionary(@"C:\Aliases.dat");// Import aliases from a fileindex.Dictionaries.AliasDictionary.ImportDictionary(@"C:\Aliases.dat");// Search in the indexSearchResultresult=index.Search("@t OR @e");
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: