我在Lucene数据库中插入了一个日期字段,代码如下:
Document.Add(new NumericField("TimeStamp", Field.Store.YES, true).SetLongValue(Data.TimeStamp.ToBinary()));
我有以下问题:
var Sort = new Sort(new SortField("TimeStamp", SortField.LONG, true));
var ParsedQuery = ParseQuery(_Parser, SearchQuery);
var Filter = new QueryWrapperFilter(ParsedQuery);
var Hits = _Searcher.Search(ParsedQuery, Filter, Skip + Limit, Sort);
但是在使用以下内容执行搜索方法时崩溃:
A first chance exception of type 'Lucene.Net.QueryParsers.QueryParser.LookaheadSuccess' occurred in Lucene.Net.dll
A first chance exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
A first chance exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
A first chance exception of type 'System.AccessViolationException' occurred in HDIndexing.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
如果我用其中一个常量替换Sort变量,例如 Sort.RELEVANCE ,那么搜索工作正常。
问题来自我的自定义搜索。
顺便说一下,我注意到其他一些奇怪的东西,我不知道这些是否是连接:如果我用Luke工具检查我的Lucene DB,我的所有字段都被报告为字符串:
http://i.stack.imgur.com/SnlSD.png
我不知道这是否是Luke中的一个错误,或者Lucene是如何设置的。 我试图将排序更改为类型'字符串'以查看会发生什么,但它会以相同的方式崩溃,所以无论哪种方式,字段的类型似乎都没有影响。
之前有没有人遇到过这个问题?
它可能类似于其他人的帖子:lucene.net sort not working access violation