如何在 Nhibernate.Search (Lucene.Net) 中构建索引?
我正在尝试向我的网站 (ASP.NET MVC 2) 添加一个搜索字段,并被告知使用 Nhibernate.Search 是一个好主意,因为我已经在项目的其余部分中使用了 Nhibernate。
不管怎样,我遵循了 coupe 教程,即 这个,以及这个网站上的一些问答,但最终没有建立索引,搜索结果为空。
我知道这个问题可能有点模糊,但奇怪的是,即使我做了我被告知的所有事情,也没有任何效果。
嗯,几乎一切。在某个教程中,它告诉我输入:
using (IFullTextSession s = Search.CreateFullTextSession(sf.OpenSession(new SearchInterceptor()))) {
QueryParser qp = new QueryParser("id", new StopAnalyzer());
IQuery NHQuery = s.CreateFullTextQuery(qp.Parse("Summary:series"), typeof(Book));
IList result = NHQuery.List();
Debug.Assert(result.Count == 2);
}
wich 不起作用,因为 SearchInterceptor 在任何地方都不存在......
我在这里遗漏了什么吗? 有没有更好的方法来编写搜索查询? 它在我的应用程序的哪一部分构建索引?
提前致谢。
I'm trying to add a search field to my web site (ASP.NET MVC 2) and was told it'd be a good idea to use Nhibernate.Search, seeing that I was already using Nhibernate in the rest of the project.
Anyway, I followed a coulpe tutorials, namely this one, and some questions and answeres on this site, but in the end, it does not build an index, and searches come empty.
I know this question might be a bit vague, but it seems strange that nothing works even after I've done everything I was told.
Well, almost everything. At some point, in one of the tutorials, it tells me to type:
using (IFullTextSession s = Search.CreateFullTextSession(sf.OpenSession(new SearchInterceptor()))) {
QueryParser qp = new QueryParser("id", new StopAnalyzer());
IQuery NHQuery = s.CreateFullTextQuery(qp.Parse("Summary:series"), typeof(Book));
IList result = NHQuery.List();
Debug.Assert(result.Count == 2);
}
wich does not work because SearchInterceptor does not exist anywhere...
Am I missing something here?
Is there a way to better write the search queries?
In which part of my application does it build the index?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试过类似的方法:
但是很慢,但似乎效果很好......
看:
https://stackoverflow.com/questions/6989125/lucene- net-nhibernate-updating-lucene-index-from-existing-data
I've tried something like:
But is slow, but it seems to work nice...
See:
https://stackoverflow.com/questions/6989125/lucene-net-nhibernate-updating-lucene-index-from-existing-data