lucene--索引的创建
来源:互联网 发布:软件导刊 核心期刊 编辑:程序博客网 时间:2024/04/30 15:56
public class IndexUtil { private String[] ids = { "1", "2", "3", "4", "5", "6" }; private String[] emails = { "aa@qq.com", "bb@sina.com", "cc@nuc.com", "dd@qq.com", "ee@sina.com", "ff@nuc.com" }; private String[] contents = { "My father was a self-taught mandolin player.", "Love your parents. We are too busy growing up yet we forget that they are already growing old", "Age has reached the end of the beginning of a word.", "As we drove off from Columbia, I wanted to write a letter to you to tell you all that is on my mind.", "The past is gone and static. Nothing we can do will change it. ", "I will persist until I succeed." }; private int[] attachs = { 3, 1, 8, 5, 2, 7 }; private String[] names = { "zhangsan", "lisi", "wangwu", "Tom", "jack", "Rose" }; private Directory directory = null; public IndexUtil() { try { directory = FSDirectory.open(new File("D:/lucene/index02")); } catch (IOException e) { e.printStackTrace(); } } public void index() { IndexWriter writer = null; Document document = null; try { writer = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_35, new StandardAnalyzer(Version.LUCENE_35))); for(int i = 0; i < ids.length; i++){ document = new Document(); document.add(new Field("id", ids[i], Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); document.add(new Field("email", emails[i], Field.Store.YES, Field.Index.NOT_ANALYZED)); document.add(new Field("content", contents[i], Field.Store.NO, Field.Index.ANALYZED)); document.add(new Field("name", names[i], Field.Store.YES, Field.Index.NOT_ANALYZED_NO_NORMS)); writer.addDocument(document); } } catch (CorruptIndexException e) { e.printStackTrace(); } catch (LockObtainFailedException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { try { if(writer != null){ writer.close(); } } catch (CorruptIndexException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }
0 0
- lucene--索引的创建
- Lucene创建索引的过程
- lucene学习之创建索引的方式
- 基于lucene的案例开发:创建索引
- Lucene搜索已经创建好的索引
- lucene学习----创建索引
- lucene创建索引
- Java_ABC_3.Lucene创建索引
- Lucene 索引创建
- LUCENE创建索引【鸡蛋】
- Lucene 索引创建
- lucene--创建索引,搜索
- lucene创建索引
- Lucene 4.4 创建索引
- Lucene.Net创建索引
- lucene 索引创建查询
- Lucene 索引创建 .
- lucene创建索引
- 《剑指Offer》面试题四之替换空格
- JVM垃圾收集算法
- 类中static function的重要作用
- UVM概述及uvm_component和uvm_object(一)
- Redis常用命令(String数据类型的操作)
- lucene--索引的创建
- 【Android】图形图像处理
- HQL语句多表联合查询,Mysql不设置外键关系
- SpringMVC学习(四)之使用POJO作为参数
- 1.8已知2000.1.1是星期六,根据任意给定的日期(2000年以后的),请编程计算出该天是星期几
- 【每天一个Linux命令】B-badblocks
- 什么情况下C++编译器会生成默认的构造函数
- CMS GC
- 理解Ionic 2之class及其修饰器@App、@Pipe