The StopWordDictionary class is designed to store stop words in an index. Information on using stop words during indexing is provided on the Indexing with stop words page.
To get the number of stop words in the dictionary, use the Count property.
To add stop words to the dictionary, use the AddRange method.
To remove words from the dictionary, use the RemoveRange method.
To check for a word in a dictionary, use the Contains method.
To remove all words from the dictionary, use the Clear method.
The following example demonstrates the use of methods of the stop word dictionary.
C#
stringindexFolder=@"c:\MyIndex\";// Creating an index from in specified folderIndexindex=newIndex(indexFolder);if(index.Dictionaries.StopWordDictionary.Count>0){// Removing all words from the dictionaryindex.Dictionaries.StopWordDictionary.Clear();}// Adding stop words to the dictionarystring[]words=newstring[]{"a","an","the","but","by"};index.Dictionaries.StopWordDictionary.AddRange(words);if(index.Dictionaries.StopWordDictionary.Contains("but")&&index.Dictionaries.StopWordDictionary.Contains("by")){// Removing words from the dictionaryindex.Dictionaries.StopWordDictionary.RemoveRange(newstring[]{"but","by"});}// Export words to a fileindex.Dictionaries.StopWordDictionary.ExportDictionary(@"C:\Words.txt");// Import words from a fileindex.Dictionaries.StopWordDictionary.ImportDictionary(@"C:\Words.txt");
More resources
GitHub examples
You may easily run the code from documentation articles and see the features in action in our GitHub examples: