@@ -0,0 +1,1079 @@
+package searching;%0D%0A%0D%0Aimport junit.framework.TestCase;%0D%0A%0D%0Aimport org.apache.lucene.index.Term;%0D%0Aimport org.apache.lucene.search.IndexSearcher;%0D%0Aimport org.apache.lucene.search.Query;%0D%0Aimport org.apache.lucene.search.TermQuery;%0D%0Aimport org.apache.lucene.search.TopDocs;%0D%0Aimport org.apache.lucene.store.Directory;%0D%0A%0D%0Aimport common.TestUtil;%0D%0A%0D%0A/***%0D%0A * Chapter 3.1.1 Listing 3.1%3Cbr%3E%0D%0A * Simple searching with TermQuery%0D%0A * @author Zhang Gang%0D%0A * @date 2014%E5%B9%B411%E6%9C%8813%E6%97%A5%0D%0A */%0D%0Apublic class BasicSearchingTest extends TestCase%7B%0D%0A%09%0D%0A%09public void testTerm() throws Exception %7B%0D%0A%09%09Directory dir = TestUtil.getBookIndexDirectory();%0D%0A%09%09IndexSearcher searcher = new IndexSearcher(dir);%0D%0A%09%09%0D%0A%09%09Term t = new Term(%22subject%22, %22ant%22);%0D%0A%09%09Query query = new TermQuery(t);%0D%0A%09%09TopDocs docs = searcher.search(query, 10);%0D%0A%09%09assertEquals(%22Ant in Action%22, 1, docs.totalHits);%0D%0A%09%09%0D%0A%09%09t = new Term(%22subject%22, %22junit%22);%0D%0A%09%09docs = searcher.search(new TermQuery(t), 10);%0D%0A%09%09assertEquals(%22Ant in Action, %22 + %22JUnit in Action, Second Edition%22, 2, docs.totalHits);%0D%0A%09%09searcher.close();%0D%0A%09%09dir.close();%0D%0A%09%7D%0D%0A%09%09%09%0D%0A%7D%0D%0A

add a search test case