Mercurial Hosting > luan
comparison src/goodjava/lucene/api/LuceneIndexWriter.java @ 1476:7d145095cc0b
lucene.logging check
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 19 Apr 2020 20:42:26 -0600 |
parents | 5e3870618377 |
children | f848d40b3b07 |
comparison
equal
deleted
inserted
replaced
1475:c7b86342857f | 1476:7d145095cc0b |
---|---|
17 import org.apache.lucene.index.IndexWriter; | 17 import org.apache.lucene.index.IndexWriter; |
18 import org.apache.lucene.index.IndexWriterConfig; | 18 import org.apache.lucene.index.IndexWriterConfig; |
19 import org.apache.lucene.index.Term; | 19 import org.apache.lucene.index.Term; |
20 import org.apache.lucene.index.DirectoryReader; | 20 import org.apache.lucene.index.DirectoryReader; |
21 import org.apache.lucene.index.IndexReader; | 21 import org.apache.lucene.index.IndexReader; |
22 import org.apache.lucene.index.CheckIndex; | |
22 import org.apache.lucene.search.Query; | 23 import org.apache.lucene.search.Query; |
23 import org.apache.lucene.search.IndexSearcher; | 24 import org.apache.lucene.search.IndexSearcher; |
24 import org.apache.lucene.store.Directory; | 25 import org.apache.lucene.store.Directory; |
25 import org.apache.lucene.util.Version; | 26 import org.apache.lucene.util.Version; |
27 import goodjava.logging.Logger; | |
28 import goodjava.logging.LoggerFactory; | |
26 | 29 |
27 | 30 |
28 public final class LuceneIndexWriter implements GoodIndexWriter { | 31 public final class LuceneIndexWriter implements GoodIndexWriter { |
32 private static final Logger logger = LoggerFactory.getLogger(LuceneIndexWriter.class); | |
29 private final FieldAnalyzer fieldAnalyzer = new FieldAnalyzer(); | 33 private final FieldAnalyzer fieldAnalyzer = new FieldAnalyzer(); |
30 public final Version luceneVersion; | 34 public final Version luceneVersion; |
31 public final IndexWriterConfig luceneConfig; | 35 public final IndexWriterConfig luceneConfig; |
32 public final IndexWriter luceneWriter; | 36 public final IndexWriter luceneWriter; |
33 public final GoodIndexWriterConfig goodConfig; | 37 public final GoodIndexWriterConfig goodConfig; |
178 } | 182 } |
179 | 183 |
180 public IndexReader openReader() throws IOException { | 184 public IndexReader openReader() throws IOException { |
181 return DirectoryReader.open(luceneWriter.getDirectory()); | 185 return DirectoryReader.open(luceneWriter.getDirectory()); |
182 } | 186 } |
187 | |
188 public void check() throws IOException { | |
189 CheckIndex.Status status = new CheckIndex(luceneWriter.getDirectory()).checkIndex(); | |
190 if( !status.clean ) | |
191 logger.error("index not clean"); | |
192 } | |
183 } | 193 } |