SynonymIndexSearcher { public TopDocs searchDocumentByWord(String word) { if (word == null) { return null; } String tempWord = word.trim(); if ("".equals(tempWord)) { return null; } TopDocs docs = null; try { final IndexSearcher searcher = mgr.acquire(); Query query = createWordQueryFor(tempWord); docs = searcher.search(query, topDocLimit); mgr.release(searcher); } catch (IOException e) { LOGGER.error(e.getMessage(), e); } return docs; } @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 testSearchDocumentByWord() { SynonymIndexSearcher searcher = getSearcher(); String bigblue[] = { "big blue", "Big Blue" }; for (int i = 0; i < bigblue.length; i++) { String toFind = bigblue[i]; TopDocs doc = searcher.searchDocumentByWord(toFind); doAssertEquals("we should have found no document, check the code", true, doc.totalHits.value == 0); } String words[] = { "I.B.M.", "ANPE" }; for (int i = 0; i < words.length; i++) { String w = words[i]; TopDocs doc = searcher.searchDocumentByWord(w); doAssertEquals("we should have found at least one document, check the list of synonyms or the code", false, doc.totalHits.value == 0); } searcher.close(); }