diff options
author | Florian Zschocke <florian.zschocke@devolo.de> | 2017-01-21 19:09:18 +0100 |
---|---|---|
committer | Florian Zschocke <florian.zschocke@devolo.de> | 2017-03-05 20:27:21 +0100 |
commit | 71e24e22cca3f85996b8a0d1951311b4592f2213 (patch) | |
tree | 8ff10cd33eb7454bbed37419a6457e467519a7ca /src/main/java/com/gitblit/tickets | |
parent | 8130906c48dcd4886bb8b28a6c1055489b499140 (diff) | |
download | gitblit-71e24e22cca3f85996b8a0d1951311b4592f2213.tar.gz gitblit-71e24e22cca3f85996b8a0d1951311b4592f2213.zip |
Replace deprecated BooleanQuery constructor with builder.
Also replace deprecated `search` method with the one without a filter
argument, since the filter isn't used anyhow.
Diffstat (limited to 'src/main/java/com/gitblit/tickets')
-rw-r--r-- | src/main/java/com/gitblit/tickets/TicketIndexer.java | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/main/java/com/gitblit/tickets/TicketIndexer.java b/src/main/java/com/gitblit/tickets/TicketIndexer.java index 652323a4..b765cc66 100644 --- a/src/main/java/com/gitblit/tickets/TicketIndexer.java +++ b/src/main/java/com/gitblit/tickets/TicketIndexer.java @@ -200,8 +200,7 @@ public class TicketIndexer { IndexWriter writer = getWriter(); StandardAnalyzer analyzer = new StandardAnalyzer(); QueryParser qp = new QueryParser(Lucene.rid.name(), analyzer); - BooleanQuery query = new BooleanQuery(); - query.add(qp.parse(repository.getRID()), Occur.MUST); + BooleanQuery query = new BooleanQuery.Builder().add(qp.parse(repository.getRID()), Occur.MUST).build(); int numDocsBefore = writer.numDocs(); writer.deleteDocuments(query); @@ -286,8 +285,7 @@ public class TicketIndexer { private boolean delete(String repository, long ticketId, IndexWriter writer) throws Exception { 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); + BooleanQuery query = new BooleanQuery.Builder().add(qp.parse(StringUtils.getSHA1(repository + ticketId)), Occur.MUST).build(); int numDocsBefore = writer.numDocs(); writer.deleteDocuments(query); @@ -331,23 +329,23 @@ public class TicketIndexer { StandardAnalyzer analyzer = new StandardAnalyzer(); try { // search the title, description and content - BooleanQuery query = new BooleanQuery(); + BooleanQuery.Builder bldr = new BooleanQuery.Builder(); QueryParser qp; qp = new QueryParser(Lucene.title.name(), analyzer); qp.setAllowLeadingWildcard(true); - query.add(qp.parse(text), Occur.SHOULD); + bldr.add(qp.parse(text), Occur.SHOULD); qp = new QueryParser(Lucene.body.name(), analyzer); qp.setAllowLeadingWildcard(true); - query.add(qp.parse(text), Occur.SHOULD); + bldr.add(qp.parse(text), Occur.SHOULD); qp = new QueryParser(Lucene.content.name(), analyzer); qp.setAllowLeadingWildcard(true); - query.add(qp.parse(text), Occur.SHOULD); + bldr.add(qp.parse(text), Occur.SHOULD); IndexSearcher searcher = getSearcher(); - Query rewrittenQuery = searcher.rewrite(query); + Query rewrittenQuery = searcher.rewrite(bldr.build()); log.debug(rewrittenQuery.toString()); @@ -406,7 +404,7 @@ public class TicketIndexer { sort = new Sort(Lucene.fromString(sortBy).asSortField(desc)); } int maxSize = 5000; - TopFieldDocs docs = searcher.search(rewrittenQuery, null, maxSize, sort, false, false); + TopFieldDocs docs = searcher.search(rewrittenQuery, maxSize, sort, false, false); int size = (pageSize <= 0) ? maxSize : pageSize; int offset = Math.max(0, (page - 1) * size); ScoreDoc[] hits = subset(docs.scoreDocs, offset, size); |