Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我们希望能够返回具有特定字段最大值的单个文档。一个典型的例子是,
max(date_time_field:*)
它返回索引中的最新文档。
Lucene.Net 中是否有类似的支持?
我不确定您是如何查询索引的,但您当然可以按相关字段排序,然后只需获取顶部文档:
var sortBy = new Sort(new SortField("date_time_field", SortField.DOUBLE, true)); var hits = ... IndexSearcher.Search(query, null, 1, sortBy)); ... var doc = searcher.IndexSearcher.Doc(hits.ScoreDocs[0]);