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

推荐订阅源

Vercel News
Vercel News
Recorded Future
Recorded Future
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The GitHub Blog
The GitHub Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Google DeepMind News
Google DeepMind News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
M
MIT News - Artificial intelligence
云风的 BLOG
云风的 BLOG
Y
Y Combinator Blog
N
News | PayPal Newsroom
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Help Net Security
Help Net Security
博客园 - Franky
SecWiki News
SecWiki News
Recent Announcements
Recent Announcements
T
Troy Hunt's Blog
The Register - Security
The Register - Security
The Last Watchdog
The Last Watchdog
Webroot Blog
Webroot Blog
S
Security Affairs
博客园 - 司徒正美
S
Schneier on Security
I
InfoQ
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Threat Research - Cisco Blogs
Forbes - Security
Forbes - Security
腾讯CDC
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic
Cloudbric
Cloudbric
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
A
About on SuperTechFans
Engineering at Meta
Engineering at Meta
Recent Commits to openclaw:main
Recent Commits to openclaw:main
B
Blog
V
Vulnerabilities – Threatpost
C
Check Point Blog
Google DeepMind News
Google DeepMind News
Google Online Security Blog
Google Online Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
Cisco Blogs
Schneier on Security
Schneier on Security
O
OpenAI News
K
Kaspersky official blog

博客园 - searchDM

Elasticsearch 集成 Elasticsearch 环境 Elasticsearch 优化 Elasticsearch入门 Elasticsearch概述 吴恩达自然语言处理第一课:分类与向量空间 Linux下C语言字符串操作之字符串转数值型 lucene 3.4 contrib/facet 切面搜索 在ubuntu上安装全文搜索中文分词Coreseek/sphinx及和Rails集成 solr3.4 高亮(highlight),拼写检查(spellCheck),匹配相似(moreLikeThis) 应用实践 堆与堆排序 Trie树|字典树的简介及实现 快速排序 归并排序的实现 直接选择排序及交换二个数据的实现 冒泡排序 直接插入排序的三种实现 希尔排序的实现 几乎所有食物的英文翻译
Lucene.net搜索结果排序(单条件和多条件)
searchDM · 2011-08-10 · via 博客园 - searchDM

Lucene支持对搜索条件的排序,一个条件或者多个条件,以及是升序还是降序,部分代码如下:

        string INDEX_STORE_PATH = Server.MapPath("index");  //INDEX_STORE_PATH 为索引存储目录
        string keyword = TextBox2.Text;                     //搜索内容

        Hits myhit 
= null;
         
        IndexSearcher mysea 
= new IndexSearcher(INDEX_STORE_PATH);
        QueryParser q 
= new QueryParser("indexcontent"new StandardAnalyzer());
        Query query 
= q.Parse(keyword);

        Sort sort 

= new Sort();
        SortField f 
= new SortField("createdate", SortField.STRING, true);//按照createdate字段排序,true表示降序
        sort.SetSort(f);//多个条件排序
        
//Sort sort = new Sort();
        
//SortField f1 = new SortField("createdate", SortField.DOC, true);
        
//SortField f2 = new SortField("bookname", SortFiedl.INT, false);
        
//sort.setSort(new SortField[] { f1, f2 });        myhit = mysea.Search(query, sort);
        Response.Write(
"关于:" + keyword + "  搜索到" + myhit.Length() + "个结果<br>");

对于数据量大(索引文件大于50M)的索引,尽量不要用索引中的字段排序,要用索引ID排序(INDEXORDER);两者效率相差近10倍。