summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLuca Milanesio <luca.milanesio@gmail.com>2016-12-22 00:42:56 +0000
committerFlorian Zschocke <florian.zschocke@devolo.de>2017-03-05 20:20:57 +0100
commit2e03db322ea93cac67275bdd584a67b559ed185a (patch)
treee9ec908d649f975a00f676dc850baa7248cd9023 /src
parent71211a8cdfae8d528130cedf3e67d21e130ee8a0 (diff)
downloadgitblit-2e03db322ea93cac67275bdd584a67b559ed185a.tar.gz
gitblit-2e03db322ea93cac67275bdd584a67b559ed185a.zip
Bump to Lucene 5.5.2
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/gitblit/service/LuceneService.java22
-rw-r--r--src/main/java/com/gitblit/tickets/TicketIndexer.java30
2 files changed, 26 insertions, 26 deletions
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<SearchResult> results = new LinkedHashSet<SearchResult>();
- 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..02af25ef 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_5_2;
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<QueryResult> results = new LinkedHashSet<QueryResult>();
- 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<QueryResult> results = new LinkedHashSet<QueryResult>();
- 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);
}