comparison lucene/src/luan/modules/lucene/LuceneIndex.java @ 303:fdb4bd391c28

add lucene close(); add Web_server.start(); git-svn-id: https://luan-java.googlecode.com/svn/trunk@304 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Thu, 18 Dec 2014 07:51:29 +0000
parents 4d53e9fc1bd9
children d34be4588556
comparison
equal deleted inserted replaced
302:2f8938fc518c 303:fdb4bd391c28
37 private final File indexDir; 37 private final File indexDir;
38 final SnapshotDeletionPolicy snapshotDeletionPolicy; 38 final SnapshotDeletionPolicy snapshotDeletionPolicy;
39 final IndexWriter writer; 39 final IndexWriter writer;
40 private DirectoryReader reader; 40 private DirectoryReader reader;
41 private LuceneSearcher searcher; 41 private LuceneSearcher searcher;
42 final FieldTable fields = new FieldTable(); 42 public final FieldTable fields = new FieldTable();
43 43
44 public LuceneIndex(LuanState luan,String indexDirStr) throws LuanException, IOException { 44 public LuceneIndex(LuanState luan,String indexDirStr) throws LuanException, IOException {
45 File indexDir = new File(indexDirStr); 45 File indexDir = new File(indexDirStr);
46 this.indexDir = indexDir; 46 this.indexDir = indexDir;
47 Directory dir = FSDirectory.open(indexDir); 47 Directory dir = FSDirectory.open(indexDir);
181 } finally { 181 } finally {
182 searcher.close(); 182 searcher.close();
183 } 183 }
184 } 184 }
185 185
186 private void add(LuanTable t,String method,Class<?>... parameterTypes) throws NoSuchMethodException { 186 public void close() throws IOException {
187 t.put( method, new LuanJavaFunction(LuceneIndex.class.getMethod(method,parameterTypes),this) ); 187 writer.close();
188 } 188 reader.close();
189
190 public LuanTable table() {
191 LuanTable tbl = Luan.newTable();
192 try {
193 tbl.put("fields",fields);
194 add( tbl, "to_string" );
195 add( tbl, "backup", LuanState.class, String.class );
196 add( tbl, "Writer", LuanState.class, LuanFunction.class );
197 add( tbl, "Searcher", LuanState.class, LuanFunction.class );
198 add( tbl, "delete_all" );
199 add( tbl, "map_field_name", String.class );
200 } catch(NoSuchMethodException e) {
201 throw new RuntimeException(e);
202 }
203 return tbl;
204 } 189 }
205 190
206 } 191 }