the usage of lucene
来源:互联网 发布:免费文档加密软件 编辑:程序博客网 时间:2024/06/03 02:27
1 create index
IndexWriter writer = new IndexWriter(index path,new SimpleAnalyzer(),true);
index path: location of index
new SimpleAnalyzer():
there are four analyers in lucene:
WhitespaceAnalyzer : only remove white space ,not lowcase and not support chinese.
simpleAnalyzer: stronger than whitespaceAnalyzer,filter all string except letter and lowcase but not support chinese.
StopAnalyzer: StopAnalyzer的功能超越了SimpleAnalyzer,在SimpleAnalyzer的基础上.增加了去除StopWords的功能,不支持中文.类中使用一个static数组保存了ENGLISH_STOP_WORDS, 太常见不index的words
StandardAnalyzer: 用Javacc定义的一套EBNF,严禁的语法。有人说英文的处理能力同于StopAnalyzer.支持中文采用的方法为单字切分。未仔细比较,不敢确定。
其他的扩展:
ChineseAnalyzer:来自于Lucene的sand box.性能类似于StandardAnalyzer,缺点是不支持中英文混和分词.
CJKAnalyzer:chedong写的CJKAnalyzer的功能在英文处理上的功能和StandardAnalyzer相同.但是在汉语的分词上,不能过滤掉标点符号,即使用二元切分
TjuChineseAnalyzer: http://windshowzbf.bokee.com/3016397.html写的,功能最为强大.TjuChineseAnlyzer的功能相当强大,在中文分词方面由于其调用的为ICTCLAS的java接口.所以其在中文方面性能上同与ICTCLAS.其在英文分词上采用了Lucene的StopAnalyzer,可以去除 stopWords,而且可以不区分大小写,过滤掉各类标点符号.
the third parameter: true is that create new index or override the old index file.
false is that append new content to old file.
final Document doc = new Document();
doc.add();
writer.add(doc);
2 search content
IndexSearch search = new IndexSearch(index path);
final Query query = QueryParser.parse(queryString, KEYWORD_CONTENT, new SimpleAnalyzer());
queryString: the key word that need search.
KEYWORD_CONTENT:the default field for query terms.
hits = searcher.search(query);
3 get search content
hits.doc(i).get(FIELD_ID)
- the usage of lucene
- The usage of finalize()
- usage of the serialVersionUID
- The usage of SQLPATH
- the usage of sscanf()
- the usage of vim
- The usage of #pragma
- The usage of InjectView
- Usage of the vc timer
- The Usage of map::insert
- The Usage of Java Timer
- the usage of keyword const
- the usage of android viewpage
- The usage of V$PGA_TARGET_ADVICE
- the usage of String.trim()
- the usage of getClass().getName()
- The Usage of the volatile Keyword
- About the Usage of fseek and ftell
- “嵌入式实时系统的DSP软件开发——多核架构”Notes
- c#自定义控件类库
- 扑克牌发牌器
- 求素数的算法
- 扫描枪扫不到条码读不到条形码的解决方法
- the usage of lucene
- 你注意过不锈钢餐具安全吗?
- 利用sqoop将hive数据导入导出数据到mysql (转)
- 基于DSP平台的音视频编解码C代码优化方法
- PL/SQL Developer常用配置(推荐)
- sizeof与strlen()的区别
- 分享34个超现实的iOS应用图标设计
- Oracle 10g Scheduler 特性
- 【LGame入门学堂008.控件篇】简单控件之LButton