Alias dictionary

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 getCount method.

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.

String indexFolder = "c:\\MyIndex\\";
// Creating or opening an index from the specified folder
Index index = new Index(indexFolder);
if (index.getDictionaries().getAliasDictionary().getCount() > 0) {
    // Deleting all existing aliases
// Adding aliases to the alias dictionary
index.getDictionaries().getAliasDictionary().add("t", "(theory OR relativity)");
index.getDictionaries().getAliasDictionary().add("e", "(Einstein OR Albert)");
AliasReplacementPair[] pairs = new AliasReplacementPair[] {
    new AliasReplacementPair("d", "daterange(2017-01-01 ~~ 2019-12-31)"),
    new AliasReplacementPair("n", "(100 ~~ 900)"),
if (index.getDictionaries().getAliasDictionary().contains("e")) {
    // Getting an alias replacement
    String replacement = index.getDictionaries().getAliasDictionary().getText("e");
    System.out.println("e - " + replacement);
// Export aliases to a file
// Import aliases from a file
// Search in the index
SearchResult result ="@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:

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.