lucene入门-建立索引
来源:互联网 发布:mac os 杀毒软件 编辑:程序博客网 时间:2024/06/05 03:01
打开eclipse,建立新工程
package bindex;
import java.io.IOException;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.CorruptIndexException;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.LockObtainFailedException;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
public class basicindexer {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String indexPath ="indexes";
try {
IndexWriter indexWriter = new IndexWriter(indexPath,new StandardAnalyzer());
Document doc=new Document();
String blogtitle="计算机软件技术与理论交流";
String blogauthor="深未来工作室(deepfuture@qq.com)-深度创造未来";
String blogurl="http://blog.163.com/sukerl@126/";
Field field=new Field("title",blogtitle,Field.Store.YES,Field.Index.TOKENIZED);
doc.add(field);
field=new Field("author",blogtitle,Field.Store.YES,Field.Index.TOKENIZED);
doc.add(field);
field=new Field("url",blogurl,Field.Store.YES,Field.Index.NO);
doc.add(field);
indexWriter.addDocument(doc);
indexWriter.close();
System.out.println("OK!");
} catch (CorruptIndexException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (LockObtainFailedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
运行后,索引建立成功
- lucene入门-建立索引
- lucene入门-复杂索引建立
- lucene--建立索引
- [lucene]索引建立
- lucene--建立索引
- 使用Lucene建立索引
- Lucene索引建立
- Lucene-建立索引
- Lucene索引的建立
- Lucene建立索引库
- Lucene---建立索引初步
- Lucene建立索引笔记
- lucene建立索引
- Lucene入门之索引的建立和优化
- Lucene从入门到熟悉(一)概念&建立索引
- lucene入门-索引网页
- lucene入门-索引网页
- Lucene创建索引入门
- MYSQL 基本命令
- HIbernate Criteria Query
- lucene入门-复杂索引建立
- Struts2源代码分析(一)配置文件加载
- DataDirectory是什么?
- lucene入门-建立索引
- 解压文件夹中的压缩文件 Python脚本
- upload file
- ASP.NET 主题(Themes)FAQ
- Java经典题目
- 数据挖掘成功人士给数据挖掘者的建议
- ORM框架试验
- 3dmax
- [软件调试----读书笔记]局部(变量)上下文