针对排序,lucene3.0有好几种写法,如下: 1)无参数排序写法: TopDocs topDocs = searcher.search(query, 10);//Lucene默认相关性排序,数字表示查询前几条 2)Sort实现排序: topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);//Sort静态常量实现相关性排序数字表示查询前几条 topDocs = searcher.search(query, null, 10, new Sort());//Sort默认构造函数实现相关性排序 topDocs = searcher.search(query, null, 10, new Sort(new SortField("sortField", SortField.DOC, true)));//Sort对象实现自定义排序 true:DESC false:ASC 相关性(评分)升降只需要修改Sort()机构里的参数,例如: new Sort(new SortField[]{SortField.FIELD_SCORE,new SortField(null, SortField.DOC, sortDesc)}); // 评分降序,评分一样时后索引的排前面 new SortField[] { SortField.FIELD_SCORE, new SortField(null, SortField.DOC, true) } // 评分升序,评分一样时后索引的排前面,呵呵,此为最不相关的排前面,挺有趣的 new SortField[] { new SortField(null, SortField.SCORE, true), new SortField(null, SortField.DOC, true) }