//create
Document doc = new Document();
//get value from JDBC ResultSet
doc.add(new LongDocValuesField("LastContactTime", rs.getLong("LastContactTime")));
//....
//Search
Sort sort = new Sort(new SortField("LastContactTime",
SortField.Type.LONG, false));
TopDocs rs = scher.search(query, total, sort);
结果未正确排序,为什么? 我正在使用Lucene4.0
答案 0 :(得分:1)
LongDocValuesField在性质上与LongField略有不同。
看起来(根据:http://www.searchworkings.org/blog/-/blogs/377217)您可以通过调用setUseIndexValues对它们进行排序,例如:
SortField field = new SortField("LastContactTime",
SortField.Type.LONG, false);
field.setUseIndexValues(true);
Sort sort = new Sort(sort);