@Test public void search() throws IOException { String[] q = {"title", "content"}; String filePath = "e:/elewordIndex/LuceneArticle"; Directory dir = FSDirectory.open(new File(filePath)); IndexReader reader = DirectoryReader.open(dir); IndexSearcher search = new IndexSearcher(reader); // Query query =SearchHelper.makeQuery("content", "网络", 0.3f); Query query = SearchHelper.makeMultiQueryFiled(q, "顶顶", 0.8f); TopDocs topDocs = search.search(query, 20); ScoreDoc[] scoreDocs = topDocs.scoreDocs; System.out.println("共:" + topDocs.totalHits + "条结果"); for (ScoreDoc doc : scoreDocs) { int docId = doc.doc; Document document = search.doc(docId); String id = document.get("id"); String title = document.get("title"); System.out.println("------------------------------------------------------------------"); System.out.println("id=" + id + " title=" + title); } }