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

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - 祥子哥哥

纪念一下我的20年的博客园。 [转]OPC.Client for DA and UA 使用C#开发库UcAsp.OPC.Client使用案例 推荐一个.Net的轻型RPC服务UcAsp.RPC Kmeans++算是DONet实现 tinymce上传文件插件。 C#中图片处理中定义显示区域[或者可以称为蒙板效果] C#生成的图片如何设置DPI Jpg保存图片确认质量 Flex在子控件操作父窗口函数 Flex 不同 application 之间传参数(转) - 祥子哥哥 刚刚写的一个加密算法 如何在DropDownList第一項加入新項目 2003服务器中出现"请求的资源在使用中"错误的解决方法 如何在.Net中访问MySQL数据库 MS SQL日志清理代码 Server Application Error Javascript检测Flash插件是否安装及版本号 最近ASP.NET WAP开发的一些情况! 数据库备份
Lucene.Net
祥子哥哥 · 2016-05-21 · via 博客园 - 祥子哥哥

创建索引

Lucene.Net.Store.Directory dir = FSDirectory.Open(AppDomain.CurrentDomain.BaseDirectory + "/index/data");
            bool flag = true;
            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "/index/data/segments.gen"))
            {
                flag = false;
            }
            IndexWriter write = new IndexWriter(dir, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT), flag, IndexWriter.MaxFieldLength.LIMITED);
            write.SetMaxFieldLength(2);


 Document doc = new Document();
                Field field0 = new Field("operation_log_ukid", f0.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
                Field field1 = new Field("related_order_ukid", f1.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
                Field field2 = new Field("related_type", f2, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
                Field field3 = new Field("operation_code", f3, Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS);
write.AddDocument(doc);
 write.Optimize();
            write.Flush(true, true, true);
            write.Dispose();
            conn.Close();

 查询索引

Lucene.Net.Store.Directory dir = FSDirectory.Open(AppDomain.CurrentDomain.BaseDirectory + "/index/data");
            IndexReader rd = DirectoryReader.Open(dir, true);

            BooleanQuery booleanQuery = new BooleanQuery();
            IndexSearcher search = new IndexSearcher(rd);

            //QueryParser parser = new QueryParser(Lucene.Net.Util.Version.LUCENE_CURRENT, "operation_name", new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT));           
            Query query = new TermRangeQuery("log_date", "2016051905", "2016052000", true, true);
            booleanQuery.Add(query,Occur.MUST);
            Query qyery2 = new QueryParser(Lucene.Net.Util.Version.LUCENE_CURRENT, "related_type", new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_CURRENT)).Parse("E");
            booleanQuery.Add(qyery2, Occur.MUST);
            Query query3 = new TermQuery(new Term("operation_log_ukid", "900216000021301"));
           booleanQuery.Add(query3, Occur.MUST);           
            TopDocs q = search.Search(booleanQuery, null, 100);
            int l = q.TotalHits;
            foreach (ScoreDoc sd in q.ScoreDocs)
            {

                Document doc = search.Doc(sd.Doc);
                long operation_log_ukid = long.Parse(doc.Get("operation_log_ukid"));
                string log_date = doc.Get("log_date");
                string related_type = doc.Get("related_type");

            }
            search.Dispose();