SynonymIndexSearcher { public int getSynonymCount(String word) { try { Query query = createWordQueryFor(word); TopDocs docs; final IndexSearcher searcher = mgr.acquire(); docs = searcher.search(query, topDocLimit); if (docs.totalHits.value > 0) { Document doc = searcher.doc(docs.scoreDocs[0].doc); String[] synonyms = doc.getValues(F_SYN); return synonyms.length; } mgr.release(searcher); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return -1; } @Deprecated  SynonymIndexSearcher();  SynonymIndexSearcher(String indexPath);   SynonymIndexSearcher(Directory indexDir); void openIndexInFS(String path); TopDocs searchDocumentByWord(String word); TopDocs searchDocumentBySynonym(String stringToSearch); int getSynonymCount(String word); Document getDocument(int docNum); String getWordByDocNumber(int docNo); String[] getSynonymsByDocNumber(int docNo); int getNumDocs(); int getMaxDoc(); int getTopDocLimit(); void setTopDocLimit(int topDocLimit); int getSlop(); void setSlop(int slop); void setAnalyzer(Analyzer analyzer); Analyzer getAnalyzer(); void close(); SynonymSearchMode getSearchMode(); void setSearchMode(SynonymSearchMode searchMode); void setMaxEdits(int maxEdits); float getMatchingThreshold(); void setMatchingThreshold(float matchingThreshold); void setMatchingThreshold(double matchingThreshold); static List<String> getTokensFromAnalyzer(String input); static final String F_WORD; static final String F_SYN; static final String F_WORDTERM; static final String F_SYNTERM; }
@Test public void testGetSynonymCount() { SynonymIndexSearcher search = new SynonymIndexSearcher(); try { search.openIndexInFS(INDEX_PATH); } catch (IOException e) { fail(e.getMessage()); } doAssertEquals("unexpected synonym count!", 2, search.getSynonymCount("IAIDQ")); search.close(); }