From: James Moger Date: Fri, 18 Sep 2015 11:54:46 +0000 (-0400) Subject: Revert "Merge pull request #915 from lucamilanesio/lucene-5.2.1" X-Git-Tag: v1.7.0~1^2~33 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=60110f769bb442494f6472d5ff3e39d596bf4130;p=gitblit.git Revert "Merge pull request #915 from lucamilanesio/lucene-5.2.1" This reverts commit 55c385e96e6594ec1ac3b5cd41ccd2df6048b696, reversing changes made to 61bb29d492ca9c34471ec0a119d1445ccde086e9. --- diff --git a/.classpath b/.classpath index b31b70c2..bd0b4372 100644 --- a/.classpath +++ b/.classpath @@ -20,15 +20,13 @@ - - - - - - - - - + + + + + + + diff --git a/build.moxie b/build.moxie index 1cfd9b85..311e26df 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 : 5.2.1 + lucene.version : 4.10.0 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 247220bf..343f24e4 100644 --- a/gitblit.iml +++ b/gitblit.iml @@ -179,101 +179,79 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/main/java/com/gitblit/service/LuceneService.java b/src/main/java/com/gitblit/service/LuceneService.java index 59b1ff24..097a39b2 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(); + writers.get(writer).close(true); } 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(); - QueryParser qp = new QueryParser(FIELD_SUMMARY, analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); + QueryParser qp = new QueryParser(LUCENE_VERSION, 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.toPath()); + Directory directory = FSDirectory.open(indexFolder); if (indexWriter == null) { if (!indexFolder.exists()) { indexFolder.mkdirs(); } - StandardAnalyzer analyzer = new StandardAnalyzer(); - IndexWriterConfig config = new IndexWriterConfig(analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); + IndexWriterConfig config = new IndexWriterConfig(LUCENE_VERSION, 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(); + StandardAnalyzer analyzer = new StandardAnalyzer(LUCENE_VERSION); try { // default search checks summary and content BooleanQuery query = new BooleanQuery(); QueryParser qp; - qp = new QueryParser(FIELD_SUMMARY, analyzer); + qp = new QueryParser(LUCENE_VERSION, FIELD_SUMMARY, analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); - qp = new QueryParser(FIELD_CONTENT, analyzer); + qp = new QueryParser(LUCENE_VERSION, 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); + TopScoreDocCollector collector = TopScoreDocCollector.create(5000, true); 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) throws IOException { + MultiSourceReader(IndexReader [] readers) { super(readers, false); } diff --git a/src/main/java/com/gitblit/tickets/TicketIndexer.java b/src/main/java/com/gitblit/tickets/TicketIndexer.java index ad8ea239..e2d53af7 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_5_2_1; + private final Version luceneVersion = Version.LUCENE_46; private final File luceneDir; @@ -201,8 +201,8 @@ public class TicketIndexer { public boolean deleteAll(RepositoryModel repository) { try { IndexWriter writer = getWriter(); - StandardAnalyzer analyzer = new StandardAnalyzer(); - QueryParser qp = new QueryParser(Lucene.rid.name(), analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); + QueryParser qp = new QueryParser(luceneVersion, 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(); - QueryParser qp = new QueryParser(Lucene.did.name(), analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); + QueryParser qp = new QueryParser(luceneVersion, 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(); + StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); try { // search the title, description and content BooleanQuery query = new BooleanQuery(); QueryParser qp; - qp = new QueryParser(Lucene.title.name(), analyzer); + qp = new QueryParser(luceneVersion, Lucene.title.name(), analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); - qp = new QueryParser(Lucene.body.name(), analyzer); + qp = new QueryParser(luceneVersion, Lucene.body.name(), analyzer); qp.setAllowLeadingWildcard(true); query.add(qp.parse(text), Occur.SHOULD); - qp = new QueryParser(Lucene.content.name(), analyzer); + qp = new QueryParser(luceneVersion, 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); + TopScoreDocCollector collector = TopScoreDocCollector.create(5000, true); 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(); + StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); try { - QueryParser qp = new QueryParser(Lucene.content.name(), analyzer); + QueryParser qp = new QueryParser(luceneVersion, 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.toPath()); + Directory directory = FSDirectory.open(luceneDir); if (!luceneDir.exists()) { luceneDir.mkdirs(); } - StandardAnalyzer analyzer = new StandardAnalyzer(); - IndexWriterConfig config = new IndexWriterConfig(analyzer); + StandardAnalyzer analyzer = new StandardAnalyzer(luceneVersion); + IndexWriterConfig config = new IndexWriterConfig(luceneVersion, analyzer); config.setOpenMode(OpenMode.CREATE_OR_APPEND); writer = new IndexWriter(directory, config); }