SynonymIndexSearcher { public Document getDocument(int docNum) { Document doc = null; try { IndexSearcher searcher = mgr.acquire(); IndexReader reader = searcher.getIndexReader(); doc = reader.document(docNum); mgr.release(searcher); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return doc; } @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 testGetDocument() { SynonymIndexSearcher search = new SynonymIndexSearcher(); try { search.openIndexInFS(INDEX_PATH); } catch (IOException e) { fail(e.getMessage()); } TopDocs docs = search.searchDocumentByWord("IAIDQ"); doAssertEquals(false, docs.totalHits.value == 0); Document document = search.getDocument(docs.scoreDocs[0].doc); assertNotNull(document); String[] values = document.getValues(SynonymIndexSearcher.F_WORD); assertNotNull(values); doAssertEquals("unexpected values!", 1, values.length); search.close(); }