From: Luca Milanesio Date: Wed, 9 Sep 2015 16:00:05 +0000 (+0100) Subject: Bump to Lucene 5.2.1 X-Git-Tag: v1.7.0~1^2~34^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e618eb051246e7941dc2964a5038587c9d45d1d2;p=gitblit.git Bump to Lucene 5.2.1 --- diff --git a/.classpath b/.classpath index bd0b4372..b31b70c2 100644 --- a/.classpath +++ b/.classpath @@ -20,13 +20,15 @@ - - - - - - - + + + + + + + + + diff --git a/build.moxie b/build.moxie index 311e26df..1cfd9b85 100644 --- a/build.moxie +++ b/build.moxie @@ -105,7 +105,7 @@ properties: { jetty.version : 9.2.10.v20150310 slf4j.version : 1.7.10 wicket.version : 1.4.21 - lucene.version : 4.10.0 + lucene.version : 5.2.1 jgit.version : 4.0.1.201506240215-r groovy.version : 2.4.1 bouncycastle.version : 1.51 diff --git a/gitblit.iml b/gitblit.iml index 343f24e4..247220bf 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -179,79 +179,101 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/gitblit/service/LuceneService.java b/src/main/java/com/gitblit/service/LuceneService.java index 097a39b2..59b1ff24 100644 --- a/src/main/java/com/gitblit/service/LuceneService.java +++ b/src/main/java/com/gitblit/service/LuceneService.java @@ -267,7 +267,7 @@ public class LuceneService implements Runnable { // close all writers for (String writer : writers.keySet()) { try { - writers.get(writer).close(true); + writers.get(writer).close(); } catch (Throwable t) { logger.error("Failed to close Lucene writer for " + writer, t); } @@ -722,8 +722,8 @@ public class LuceneService implements Runnable { String q = MessageFormat.format(pattern, SearchObjectType.blob.name(), branch, path); BooleanQuery query = new BooleanQuery(); - StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); - QueryParser qp = new QueryParser(LUCENE_VERSION, FIELD_SUMMARY, analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(); + QueryParser qp = new QueryParser(FIELD_SUMMARY, analyzer); query.add(qp.parse(q), Occur.MUST); IndexWriter writer = getIndexWriter(repositoryName); @@ -968,14 +968,14 @@ public class LuceneService implements Runnable { IndexWriter indexWriter = writers.get(repository); File repositoryFolder = FileKey.resolve(new File(repositoriesFolder, repository), FS.DETECTED); File indexFolder = new File(repositoryFolder, LUCENE_DIR); - Directory directory = FSDirectory.open(indexFolder); + Directory directory = FSDirectory.open(indexFolder.toPath()); if (indexWriter == null) { if (!indexFolder.exists()) { indexFolder.mkdirs(); } - StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); - IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(); + IndexWriterConfig config = new IndexWriterConfig(analyzer); config.setOpenMode(OpenMode.CREATE_OR_APPEND); indexWriter = new IndexWriter(directory, config); writers.put(repository, indexWriter); @@ -1028,16 +1028,16 @@ public class LuceneService implements Runnable { return null; } Set results = new LinkedHashSet(); - StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); + StandardAnalyzer analyzer = new StandardAnalyzer(); try { // default search checks summary and content BooleanQuery query = new BooleanQuery(); QueryParser qp; - qp = new QueryParser(LUCENE_VERSION, FIELD_SUMMARY, analyzer); + qp = new QueryParser(FIELD_SUMMARY, analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); - qp = new QueryParser(LUCENE_VERSION, FIELD_CONTENT, analyzer); + qp = new QueryParser(FIELD_CONTENT, analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); @@ -1060,7 +1060,7 @@ public class LuceneService implements Runnable { Query rewrittenQuery = searcher.rewrite(query); logger.debug(rewrittenQuery.toString()); - TopScoreDocCollector collector = TopScoreDocCollector.create(5000, true); + TopScoreDocCollector collector = TopScoreDocCollector.create(5000); searcher.search(rewrittenQuery, collector); int offset = Math.max(0, (page - 1) * pageSize); ScoreDoc[] hits = collector.topDocs(offset, pageSize).scoreDocs; @@ -1225,7 +1225,7 @@ public class LuceneService implements Runnable { */ private class MultiSourceReader extends MultiReader { - MultiSourceReader(IndexReader [] readers) { + MultiSourceReader(IndexReader [] readers) throws IOException { super(readers, false); } diff --git a/src/main/java/com/gitblit/tickets/TicketIndexer.java b/src/main/java/com/gitblit/tickets/TicketIndexer.java index e2d53af7..ad8ea239 100644 --- a/src/main/java/com/gitblit/tickets/TicketIndexer.java +++ b/src/main/java/com/gitblit/tickets/TicketIndexer.java @@ -167,7 +167,7 @@ public class TicketIndexer { private final Logger log = LoggerFactory.getLogger(getClass()); - private final Version luceneVersion = Version.LUCENE_46; + private final Version luceneVersion = Version.LUCENE_5_2_1; private final File luceneDir; @@ -201,8 +201,8 @@ public class TicketIndexer { public boolean deleteAll(RepositoryModel repository) { try { IndexWriter writer = getWriter(); - StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); - QueryParser qp = new QueryParser(luceneVersion, Lucene.rid.name(), analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(); + QueryParser qp = new QueryParser(Lucene.rid.name(), analyzer); BooleanQuery query = new BooleanQuery(); query.add(qp.parse(repository.getRID()), Occur.MUST); @@ -287,8 +287,8 @@ public class TicketIndexer { * @return true, if deleted, false if no record was deleted */ private boolean delete(String repository, long ticketId, IndexWriter writer) throws Exception { - StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); - QueryParser qp = new QueryParser(luceneVersion, Lucene.did.name(), analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(); + QueryParser qp = new QueryParser(Lucene.did.name(), analyzer); BooleanQuery query = new BooleanQuery(); query.add(qp.parse(StringUtils.getSHA1(repository + ticketId)), Occur.MUST); @@ -331,21 +331,21 @@ public class TicketIndexer { return Collections.emptyList(); } Set results = new LinkedHashSet(); - StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); + StandardAnalyzer analyzer = new StandardAnalyzer(); try { // search the title, description and content BooleanQuery query = new BooleanQuery(); QueryParser qp; - qp = new QueryParser(luceneVersion, Lucene.title.name(), analyzer); + qp = new QueryParser(Lucene.title.name(), analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); - qp = new QueryParser(luceneVersion, Lucene.body.name(), analyzer); + qp = new QueryParser(Lucene.body.name(), analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); - qp = new QueryParser(luceneVersion, Lucene.content.name(), analyzer); + qp = new QueryParser(Lucene.content.name(), analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); @@ -354,7 +354,7 @@ public class TicketIndexer { log.debug(rewrittenQuery.toString()); - TopScoreDocCollector collector = TopScoreDocCollector.create(5000, true); + TopScoreDocCollector collector = TopScoreDocCollector.create(5000); searcher.search(rewrittenQuery, collector); int offset = Math.max(0, (page - 1) * pageSize); ScoreDoc[] hits = collector.topDocs(offset, pageSize).scoreDocs; @@ -392,9 +392,9 @@ public class TicketIndexer { } Set results = new LinkedHashSet(); - StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); + StandardAnalyzer analyzer = new StandardAnalyzer(); try { - QueryParser qp = new QueryParser(luceneVersion, Lucene.content.name(), analyzer); + QueryParser qp = new QueryParser(Lucene.content.name(), analyzer); Query query = qp.parse(queryText); IndexSearcher searcher = getSearcher(); @@ -443,14 +443,14 @@ public class TicketIndexer { private IndexWriter getWriter() throws IOException { if (writer == null) { - Directory directory = FSDirectory.open(luceneDir); + Directory directory = FSDirectory.open(luceneDir.toPath()); if (!luceneDir.exists()) { luceneDir.mkdirs(); } - StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); - IndexWriterConfig config = new IndexWriterConfig(luceneVersion, analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(); + IndexWriterConfig config = new IndexWriterConfig(analyzer); config.setOpenMode(OpenMode.CREATE_OR_APPEND); writer = new IndexWriter(directory, config); }