我把数据库的category表用lucene索引,  但有一个要求没有输入关键字时, 怎么把所有结果查出来.
private static List<Category> doPagingSearch(Searcher searcher, String keyWord, int hitsPerPage) throws IOException { List<Category> catList = new ArrayList<Category>();
try {
// Create the QueryParser instance
QueryParser descriptionQP = new QueryParser(Version.LUCENE_30, "description", getAnalyzer()); String cleanQueryString = escapeBadCharacters(keyWord);
Query descriptionQuery = descriptionQP.parse(cleanQueryString); // Collect enough docs to show 5 pages
TopScoreDocCollector collector = TopScoreDocCollector.create(5 * hitsPerPage, false); searcher.search(descriptionQuery, collector); ScoreDoc[] hits = collector.topDocs().scoreDocs; for (int i = 0; i < hits.length; i++) {
Document doc = searcher.doc(hits[i].doc);
Category category = new Category();
category.setCatId(Long.valueOf(doc.get("catId")));
category.setDescription(doc.get("description"));
category.setParentCatId(Long.valueOf(doc.get("parentCatId")));
catList.add(category);
}
int numTotalHits = collector.getTotalHits();
System.out.println(numTotalHits + " total matching documents"); } catch (ParseException e) {
logger.severe("Search Query" + e.getMessage());
} return catList;
}