如何使用排序功能搜索 lucene.net?
我不确定如何将它用于排序。我想按日期时间降序对结果进行排序。
I am unsure that how I can use it with sorting. I want to sort the result by datetime descending.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新 (2013.04.22):较新版本的 Lucene.NET 允许更直接地按 DateTime 排序,例如:
将 CreationTime 添加为 DateTime.Ticks 以允许通过 SortField.LONG 搜索它。
我已经用3.0版本测试过了。
是的,这个问题之前已经部分回答过。但是,我想在日期时间部分添加注释。
在常规 Lucene 社区中,通常建议拆分 DateTime,以使它们足够高性能和/或足够精确(Int32 只有 10 个字符)。半年前,我对多达 500,000 个文档进行了基准测试,我记得,这确实是我能想到的唯一高效方法。
无论如何,你可以尝试这样的事情:
索引
搜索
UPDATE (2013.04.22): Newer versions of Lucene.NET allow sorting by DateTime more directly, for example:
Add the CreationTime as DateTime.Ticks to allow searching for it via SortField.LONG.
I have tested this with version 3.0.
yes, this question has partly been answered before. However, I would like to add a note on the DateTime part.
In regular Lucene communities it is offen recommended to split up DateTime's in order to make them performant and/or precise enough (Int32 is just 10 characters). I've benchmarked with up to 500.000 documents half a year ago, and as I remember, this really was the only performant way I could come up with.
Anyway, you can try out something like this:
Indexing
Searching