惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
AI
AI
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
博客园 - 三生石上(FineUI控件)
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
AWS News Blog
AWS News Blog
S
Securelist
Schneier on Security
Schneier on Security
MyScale Blog
MyScale Blog
W
WeLiveSecurity
Hacker News: Ask HN
Hacker News: Ask HN
爱范儿
爱范儿
阮一峰的网络日志
阮一峰的网络日志
Project Zero
Project Zero
Recent Commits to openclaw:main
Recent Commits to openclaw:main
P
Proofpoint News Feed
I
Intezer
人人都是产品经理
人人都是产品经理
The Register - Security
The Register - Security
T
The Exploit Database - CXSecurity.com
宝玉的分享
宝玉的分享
L
LINUX DO - 热门话题
月光博客
月光博客
C
CERT Recently Published Vulnerability Notes
F
Fortinet All Blogs
GbyAI
GbyAI
博客园 - 聂微东
F
Full Disclosure
L
LINUX DO - 最新话题
T
The Blog of Author Tim Ferriss
Engineering at Meta
Engineering at Meta
IT之家
IT之家
Scott Helme
Scott Helme
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Security Affairs
I
InfoQ
The Hacker News
The Hacker News
雷峰网
雷峰网
Hacker News - Newest:
Hacker News - Newest: "LLM"
V2EX - 技术
V2EX - 技术
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
SecWiki News
SecWiki News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
大猫的无限游戏
大猫的无限游戏
博客园_首页
B
Blog RSS Feed
S
Secure Thoughts
A
About on SuperTechFans

博客园 - 追梦华仔

Openfire服务器MySQL优化 放开Linux内核对用户进程可打开文件数和TCP连接的限制 SSL 握手协议 非对称密码学(Asymmetric Cryptography)- 转载 Visual Studio 2008下载 Visual Studio 2008 提示“无法识别工具版本4.0” 改造MUC实现Openfire群 Openfire S2S 经验分享 注册Jmail组件的三种方法 读取excel文件的时候 出错提示:外部表不是预期的格式 - 追梦华仔 - 博客园 System.Runtime.InteropServices.COMException: 服务器出现意外情况 Excel表格导入出错,提示“拒绝访问”的错误,ExcelObj = new Excel.Application(); 在 ASP.NET 中执行 URL 重写 XP下如何解决“ASP.NET 未被授权访问所请求的资源”的问题 - 追梦华仔 - 博客园 无法在web服务器上启动调试 您不具备调试此应用程序的权限 - 追梦华仔 - 博客园 Server Application Error ---Http 500错误解决方法 用Lucene实现在检索结果中再检索 [转载]Ruby on Rails:开源技术将深入企业 Lucene.Net中按时间范围查询,结果没有查到数据
Lucene.Net.Search.Highlight.FragmentQueue 中的派生方法 LessThan 不能减少访问
追梦华仔 · 2007-06-22 · via 博客园 - 追梦华仔

今天运用Lucene.net做全文索引查询时,碰到了这个问题。在baidu搜索了一下,也有朋友碰到同样的问题:

我在ASP.NET中使用Lucene.NET组件实现高亮显示..可是出现问题..说什么不能访问(如下图),另外如果在ASP.NET中建立索引后..搜索时有些东西搜索不到,在WinForm中又没事..这又是什么问题呢??请牛人们帮忙
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息: System.TypeLoadException: 程序集 Highlighter, Version=1.3.2.1, Culture=neutral, PublicKeyToken=null 的类型 Lucene.Net.Search.Highlight.FragmentQueue 中的派生方法 LessThan 不能减少访问。
源错误:
行 169: row["title"] = doc.Get("title");
行 170: row["path"] = "http://www.dotlucene.net/documentation/api/1.4/" + path.Replace("\\", "/");
行 171: row["sample"] = highlighter.GetBestFragments(plainText, 80, 2, "...");
行 172:
行 173: this.Results.Rows.Add(row);
以上是在ASP.NET中使用高亮显示时出现的问题


后来自己找到了解决办法:
原因出于Lucene.Net.dll 和 Highlighter.Net.dll的版本不一致。你要检查一下,你的项目中引用的Lucene.Net.dll是2.0的,而 Highlighter.Net.dll不是2.0的,这一点从上面“ row["sample"] = highlighter.GetBestFragments(plainText, 80, 2, "..."); ” 这句可以看出。因为2.0的GetBestFragments方法的参数列表不同,在我的解决方案中是用了
public System.String GetBestFragment ( Lucene.Net.Analysis.TokenStream tokenStream , System.String text )方法

关键代码如下:
   using Lucene.Net.Documents;
   using Lucene.Net.Analysis.Standard;
   using Lucene.Net.Search;
   using Lucene.Net.QueryParsers;
   using Lucene.Net.Index;
   using Lucene.Net.Store;
   using Lucene.Net.Highlight;
   using Lucene.Net.Analysis;
   using System.IO;

      //内容
      string text = doc.GetField("Content").StringValue();
      //某数据记录对象
     Result result = new Result();      
      // 高亮显示设置
      SimpleHTMLFormatter simpleHTMLFormatter = new SimpleHTMLFormatter("<font color=\"red\">", "</font>");
      highlighter = new Highlighter(simpleHTMLFormatter, new QueryScorer(query));     
      //关键内容显示大小设置 
      highlighter.SetTextFragmenter(new SimpleFragmenter(200));      
      //取出高亮显示内容
      TokenStream tokenStream = analyzer.TokenStream("Content", new StringReader(text));
      result.Content = highlighter.GetBestFragment(tokenStream,text);

 参考文章:http://blog.sina.com.cn/u/54c1567b010008st
http://hi.baidu.com/buliu/blog/item/115ee83d542735c59e3d6225.html
http://www.tianyablog.com/blogger/post_show.asp?BlogID=114714&PostID=2852189