From cdfb43dbd88830c0e96a54bb88e50e5a3b550e75 Mon Sep 17 00:00:00 2001 From: jendib Date: Tue, 28 Jun 2016 23:31:59 +0200 Subject: [PATCH] Cleanup Lucene DAO --- .../docs/core/dao/lucene/LuceneDao.java | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java b/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java index 104121e0..e3bafc2f 100644 --- a/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java +++ b/docs-core/src/main/java/com/sismics/docs/core/dao/lucene/LuceneDao.java @@ -34,7 +34,7 @@ public class LuceneDao { /** * Destroy and rebuild index. * - * @param fileList + * @param fileList List of files */ public void rebuildIndex(final List documentList, final List fileList) { LuceneUtil.handle(new LuceneRunnable() { @@ -103,21 +103,6 @@ public class LuceneDao { }); } - /** - * Update file index. - * - * @param file Updated file - */ - public void updateFile(final File file) { - LuceneUtil.handle(new LuceneRunnable() { - @Override - public void run(IndexWriter indexWriter) throws Exception { - org.apache.lucene.document.Document luceneDocument = getDocumentFromFile(file); - indexWriter.updateDocument(new Term("id", file.getId()), luceneDocument); - } - }); - } - /** * Delete document from the index. * @@ -166,7 +151,7 @@ public class LuceneDao { // Search DirectoryReader directoryReader = AppContext.getInstance().getIndexingService().getDirectoryReader(); - Set documentIdList = new HashSet(); + Set documentIdList = new HashSet<>(); if (directoryReader == null) { // The directory reader is not yet initialized (probably because there is nothing indexed) return documentIdList; @@ -176,8 +161,8 @@ public class LuceneDao { ScoreDoc[] docs = topDocs.scoreDocs; // Extract document IDs - for (int i = 0; i < docs.length; i++) { - org.apache.lucene.document.Document document = searcher.doc(docs[i].doc); + for (ScoreDoc doc : docs) { + org.apache.lucene.document.Document document = searcher.doc(doc.doc); String type = document.get("doctype"); String documentId = null; if (type.equals("document")) { @@ -194,7 +179,7 @@ public class LuceneDao { /** * Build Lucene document from database document. * - * @param documentDto Document + * @param document Document * @return Document */ private org.apache.lucene.document.Document getDocumentFromDocument(Document document) {