SynonymIndexBuilder { public void initIndexInFS(String path) { File file = new File(path); if (!file.exists()) { file.mkdirs(); } try { indexDir = FSDirectory.open(Paths.get(path)); } catch (IOException e) { LOG.info(e.getMessage(), e); error.set(false, Messages.getString("SynonymIndexBuilder.failLoad.withParameter", path)); } } SynonymIndexBuilder(); Error getError(); void setSynonymSeparator(char synonymSeparator); void initIndexInFS(String path); boolean insertDocument(String word, String synonyms); boolean insertDocumentIfNotExists(String word, String synonyms); int updateDocument(String word, String synonyms); int deleteDocumentByWord(String word); void deleteAllDocuments(); int addSynonymToDocument(String word, String newSynonym); int removeSynonymFromDocument(String word, String synonymToDelete); boolean deleteIndexFromFS(String path); void closeIndex(); void commit(); Analyzer getAnalyzer(); int getNumDocs();  }
@Test public void initIndexInFS() throws IOException { String indexPath = "data/index3"; SynonymIndexBuilder synonymIndexBuilder = new SynonymIndexBuilder(); synonymIndexBuilder.initIndexInFS(indexPath); synonymIndexBuilder.insertDocument("salut", "toto"); synonymIndexBuilder.commit(); SynonymIndexSearcher searcher = new SynonymIndexSearcher(indexPath); int numDocs = searcher.getNumDocs(); synonymIndexBuilder.initIndexInFS(indexPath); synonymIndexBuilder.insertDocument("bye", "au revoir"); synonymIndexBuilder.commit(); SynonymIndexSearcher searcher2 = new SynonymIndexSearcher(indexPath); assertEquals(numDocs + 1, searcher2.getNumDocs()); synonymIndexBuilder.closeIndex(); searcher.close(); searcher2.close(); String os = System.getProperties().getProperty("os.name"); if (!os.startsWith("win") && !os.startsWith("Win")) { boolean deleted = synonymIndexBuilder.deleteIndexFromFS(indexPath); assertEquals(true, deleted); } }