布尔字段的问题
我像这样索引一个布尔字段:
[Field(Index.UnTokenized, Store = Store.No)]
public virtual bool P { get; set; }
我的查询代码如下所示:
public IList<MappedSequence> Query(string term, out int total, int page, int pageSize)
{
if (term.ToString().Equals("") == false)
{
var parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new[] { "Query" }, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
Query query = parser.Parse(term);
IFullTextSession session = Search.CreateFullTextSession(this.Session);
IQuery fullTextQuery = session.CreateFullTextQuery(query, new[] { typeof(MappedSequence) });
total = fullTextQuery.List<MappedSequence>().Count();
return fullTextQuery.List<MappedSequence>().Skip((page - 1) * pageSize).Take(pageSize).ToList<MappedSequence>();
}
else
{
total = 0;
return null;
}
}
这对于其他索引字段效果很好,但不适用于布尔字段。我尝试了各种方法:
"P:\"TRUE\""
"P:\"1\""
没有成功。有什么想法可能是错的吗?
顺便说一句,有没有更有效的方法来确定总数?
谢谢!
基督教
I index a boolean field like this:
[Field(Index.UnTokenized, Store = Store.No)]
public virtual bool P { get; set; }
My query code looks like this:
public IList<MappedSequence> Query(string term, out int total, int page, int pageSize)
{
if (term.ToString().Equals("") == false)
{
var parser = new MultiFieldQueryParser(Lucene.Net.Util.Version.LUCENE_29, new[] { "Query" }, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
Query query = parser.Parse(term);
IFullTextSession session = Search.CreateFullTextSession(this.Session);
IQuery fullTextQuery = session.CreateFullTextQuery(query, new[] { typeof(MappedSequence) });
total = fullTextQuery.List<MappedSequence>().Count();
return fullTextQuery.List<MappedSequence>().Skip((page - 1) * pageSize).Take(pageSize).ToList<MappedSequence>();
}
else
{
total = 0;
return null;
}
}
This works fine for other index field but not for the boolean ones. I tried all sorts for term:
"P:\"TRUE\""
"P:\"1\""
without success. Any ideas what could be wrong?
BTW is there a more efficient way to determine total?
Thanks!
Christian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来,如果我使用 Tokenized 进行索引,它就可以工作。
基督教
It appears that if I use Tokenized for indexing it works.
Christian
我有同样的问题,但在 Lucene.Net 3.0 中,语法是“ANALYZED”
而不是“NOT_ANALYZED”:
I had the same issue,but in Lucene.Net 3.0 the syntax is "ANALYZED"
as opposed to "NOT_ANALYZED":