TempQuery public void testTerm() throws Exception {
IndexSearcher searcher = new IndexSearcher(directory);
Term t = new Term("subject", "ant");
//"subject"是域名,"ant"是查询项的值
Query query = new TermQuery(t);
Hits hits = searcher.search(query);
assertEquals("JDwA", 1, hits.length());
t = new Term("subject", "junit");
hits = searcher.search(new TermQuery(t));
assertEquals(2, hits.length());
searcher.close();
}
1)注意:查询项的值是区分大小写的。此外,由于不同的分词器的索引方式都不同,所以对原文的搜索可能还有其它问题。 2)TempQuery类在根据关键字(即通过Field.Keyword()索引过的关键字)查询文档时显得特别有用。 3)如果单个单词作为查询表达式,QueryParse的parse()函数将返回一个TermQuery对象。这个单词就相当于一个单独的项。
相关推荐
lucene in action 第二版(pdf),内为英文彩色原版。
lucene in action lucene in action lucene in action lucene in action lucene in action lucene in action lucene in action lucene in action
《lucene in action》第二版
lecene4.x教程,有很多简单明了的demo,是学习开发的好助手
lucene in action源码
Lucene In Action 第二版 高清中文版+附书源代码 Lucene In Action 第二版 高清中文版+附书源代码
lucene in action 第二版中文版,
Lucene in action 中文版 电子版,超清晰
【Manning eBook】Lucene in Action 2nd Edition MEAP新版 Jun 2010
《Lucene in Action》配套源码
Lucene In Action,入门Lucene经典教程。
Lucene In Action 2书的配套源代码
lucene in action的配套源代码
Lucene In Action 第二版 中文版 完整版
《Lucene实战 第2版 》基于Apache的Lucene 3 0 从Lucene核心 Lucene应用 案例分析3个方面详细系统地介绍了Lucene 包括认识Lucene 建立索引 为应用程序添加搜索功能 高级搜索技术 扩展搜索 使用Tika提取文本 Lucene的...
从Lucene核心、Lucene应用、案例分析3个方面详细系统地介绍了Lucene,包括认识Lucene、建立索引、为应用程序添加搜索功能、高级搜索技术、扩展搜索、使用Tika提取文本、Lucene的高级扩展、使用其他编程语言访问...
lucene in action 中文
搜索引擎 Lucene教程 对应lucnen 3.0