lucene学习笔记1--索引创建
来源:互联网 发布:安卓python编辑器 编辑:程序博客网 时间:2024/06/05 10:49
创建索引代码:
public void createIndex(String indexPath, String dataDir) throws IOException
{//获取数据源文件列表
File[] files = new File(dataDir).listFiles();
//创建索引目錄
Directory directory = FSDirectory.open(new File(indexPath));
//創建分詞器
// Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30);
Analyzer analyzer = new PaodingAnalyzer();
//创建索引写入类
IndexWriter indexWriter = new IndexWriter(directory, analyzer, true, MaxFieldLength.LIMITED);
for (File file : files)
{
String content = FileOperation.readContents(file, "UTF-8");
String[] records = content.split("\r\n");
for (String record : records)
{
//创建Document对象
Document document = new Document();
//创建域
Field contentField = new Field("content", record, Store.YES, Index.ANALYZED);
Field nameField = new Field("filename", file.getName(), Store.YES, Index.ANALYZED);
document.add(nameField);
document.add(contentField);
indexWriter.addDocument(document);
}
}
indexWriter.optimize();
//查看有多少个索引
System.out.println("numDocs:" + indexWriter.numDocs());
indexWriter.close();
}
- lucene学习笔记1--索引创建
- lucene学习笔记1-创建索引
- lucene学习----创建索引
- lucene学习笔记3-索引-创建域选项
- 深入 Lucene 索引机制-学习笔记1
- lucene学习备份---创建索引
- lucene学习之创建索引
- Lucene学习笔记(1):Lucene的索引文件格式
- 新一篇: lucene学习----创建索引 |
- Lucene学习-创建索引(一)
- Lucene学习-创建索引(二)
- lucene学习之创建索引的方式
- lucene学习--创建索引与搜索
- Lucene学习-创建索引、关键词查询
- Lucene 4.10 + Mysql 5.5 创建数据库表索引(Lucene 学习序列1)
- Lucene学习教程——Lucene索引创建
- lucene创建索引读取索引简单测试--笔记
- lucene学习笔记之索引创建、内容检索、分类器实现
- 文法系列之上下文有关语法和0型语法简介
- 求正差值
- C# SerialPort串口通信发送接收,处理接收数据完整
- jQuery 1.7 中文API (适用jQuery 1.7、jQuery 1.7.1)
- 特价机票退票费高达80% 律师称航班延误应补偿-特价机票-退票费-霸王条款
- lucene学习笔记1--索引创建
- The C programming language 1-13 水平方向直方图
- linux下安装QT
- C++ vector类的定义和使用举例
- patch
- 【Ogre编程入门与进阶】第二章 Ogre相关知识回顾
- 读取沙盒的文件,删除指定格式文件和总容量
- 中日即将举行副外长级钓鱼岛问题磋商-中日-副外长-钓鱼岛
- 学习用 doxygen 生成源码文档