Welcome 微信登录

首页 / 数据库 / MySQL / 使用Lucene 2.31 索引 Oracle 10g的数据库

1,使用主要技术:
Lucene 2.3.1
IK_CAnalyzer 1.4 中文分词
HtmlParser 1.6 HTML文件/文本解析器 缺点:不能忽略<!----->的内容
2,其他实现方法:每天做对每类做增量索引 索引内容:类型,URL,TEXT内容,标题,作者,时间。3,在Oracle 10g上建表:-- Create table
create table IZ_SEARCH_ENGINE

  ID             NUMBER not null,
  INDEX_DIR      VARCHAR2(50),
  TYPE           VARCHAR2(500),   类型
  TYPE_DESC      VARCHAR2(50),  类型注释
  TABLE_MAXVALUE VARCHAR2(50), 某表最大值
  TABLE_SQLS     CLOB,  (最某表没有被索引的SQL语句,如select .... from XXX where id>#ID# ,  #ID# 取自TABLE_MAXVALUE )
  STATUS         VARCHAR2(20) default "offline", 暂时无用
  TYPE_TRUETYPE  VARCHAR2(50) 暂时无用
)4,建立索引的JAVA关键代码:String INDEX_DIR = “/home/xue24_index_book”; //指定索引目录
IndexWriter writer = new IndexWriter(INDEX_DIR, new IK_CAnalyzer(), true); //准备索引区,并指定分词分析器
Document doc = new Document(); //实例化新document
doc.add(new Field(“type”, “社区”, Field.Store.YES, Field.Index.TOKENIZED)); //为document设置字段:type
doc.add(new Field(“title”, “标题标题” Field.Store.YES, Field.Index.TOKENIZED)); //为document设置字段:title
writer.addDocument(doc); //将该document加入索引目录
writer.optimize();  //优化
writer.close();  //关闭索引5,搜索的JSP关键代码:String INDEX_DIR_BOOK = "/home/xue24_index/book";
String INDEX_DIR_BBS = "/home/xue24_index/bbs";Searcher[] searchers=new Searcher[2];
searchers[0] = new IndexSearcher(INDEX_DIR_BOOK);
searchers[1] = new IndexSearcher(INDEX_DIR_BBS);Searcher searcher = new MultiSearcher(searchers);
MultiFieldQueryParser queryParser = new MultiFieldQueryParser(new String[] {"title","content","author" }, new IK_CAnalyzer());
Query query = queryParser.parse(keyword); //分析查询Hits hits = searcher.search(query);//  搜索索引
out.println(“共找到结果:”+hits.length());
for(int i=0;i<hits.length(); i++){
   Document doc = hits.doc(i);
   out.println(“标题:” +doc.get("title") );
}
6,再写一个linux cron 定期执行,或用quartz插件来完成增量索引。Lucene 的详细介绍:请点这里
Lucene 的下载地址:请点这里Oracle 丢失日志(redoxx_xx)文件后的处理方法Linux下使用PHP连接SQL Server 2005相关资讯      Oracle数据库  Oracle入门教程  oracle数据库教程 
  • Oracle数据库全球化  (03月01日)
  • Oracle数据库日期过滤方法性能比较  (02/02/2015 13:20:26)
  • Oracle数据库安装中端口被占用问题  (10/29/2014 07:42:24)
  • 在CentOS 6.6上搭建C++运行环境并  (10/10/2015 19:44:40)
  • Oracle数据库无法使用localhost和  (11/14/2014 16:39:10)
  • 使用SQLT来构建Oracle测试用例  (08/28/2014 06:17:41)
本文评论 查看全部评论 (0)
表情: 姓名: 字数