其實Lucene 的Search方法有結果排序的功能,加個參數,以前還本身寫個排序。html
search(Query query, int n, Sort sort)
Search implementation with arbitrary sorting and no filter.apache
查看Sort類api
Field Summary | |
---|---|
static Sort |
INDEXORDER Represents sorting by index order. |
static Sort |
RELEVANCE Represents sorting by computed relevance. |
若是按照文件號排序: Sort.INDEXORDER spa
按照類似度排序: Sort.RELEVANCEcode