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 getCount method.
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.
StringindexFolder="c:\\MyIndex\\";// Creating an index from in specified folder
Indexindex=newIndex(indexFolder);if(index.getDictionaries().getStopWordDictionary().getCount()>0){// Removing all words from the dictionary
index.getDictionaries().getStopWordDictionary().clear();}// Adding stop words to the dictionary
String[]words=newString[]{"a","an","the","but","by"};index.getDictionaries().getStopWordDictionary().addRange(words);if(index.getDictionaries().getStopWordDictionary().contains("but")&&index.getDictionaries().getStopWordDictionary().contains("by")){// Removing words from the dictionary
index.getDictionaries().getStopWordDictionary().removeRange(newString[]{"but","by"});}// Export words to a file
index.getDictionaries().getStopWordDictionary().exportDictionary("C:\\Words.txt");// Import words from a file
index.getDictionaries().getStopWordDictionary().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: