comparison lucene/src/luan/modules/lucene/LuceneIndex.java @ 524:70bda9184158

minor fix
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 27 May 2015 03:20:01 -0600
parents 8a217fe5b4f3
children ef0336efe33c
comparison
equal deleted inserted replaced
523:dcd278f02e67 524:70bda9184158
46 final IndexWriter writer; 46 final IndexWriter writer;
47 private DirectoryReader reader; 47 private DirectoryReader reader;
48 private LuceneSearcher searcher; 48 private LuceneSearcher searcher;
49 public final FieldTable fields = new FieldTable(); 49 public final FieldTable fields = new FieldTable();
50 private boolean isClosed = false; 50 private boolean isClosed = false;
51 private final Runnable closer;
51 52
52 public LuceneIndex(LuanState luan,String indexDirStr) throws LuanException, IOException { 53 public LuceneIndex(LuanState luan,String indexDirStr) throws LuanException, IOException {
53 File indexDir = new File(indexDirStr); 54 File indexDir = new File(indexDirStr);
54 this.indexDir = indexDir; 55 this.indexDir = indexDir;
55 Directory dir = FSDirectory.open(indexDir); 56 Directory dir = FSDirectory.open(indexDir);
59 snapshotDeletionPolicy = new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy()); 60 snapshotDeletionPolicy = new SnapshotDeletionPolicy(conf.getIndexDeletionPolicy());
60 conf.setIndexDeletionPolicy(snapshotDeletionPolicy); 61 conf.setIndexDeletionPolicy(snapshotDeletionPolicy);
61 writer = new IndexWriter(dir,conf); 62 writer = new IndexWriter(dir,conf);
62 writer.commit(); // commit index creation 63 writer.commit(); // commit index creation
63 reader = DirectoryReader.open(dir); 64 reader = DirectoryReader.open(dir);
64 luan.onClose(new Runnable(){public void run() { 65 closer = new Runnable(){public void run(){
65 try { 66 try {
66 close(); 67 close();
67 } catch(IOException e) { 68 } catch(IOException e) {
68 logger.error("",e); 69 logger.error("",e);
69 } 70 }
70 }}); 71 }};
72 luan.onClose(closer);
71 searcher = new LuceneSearcher(this,reader); 73 searcher = new LuceneSearcher(this,reader);
72 initId(luan); 74 initId(luan);
73 } 75 }
74 76
75 Document toLucene(LuanState luan,LuanTable table) throws LuanException { 77 Document toLucene(LuanState luan,LuanTable table) throws LuanException {