Upgrade Lucene to version 5.3.0

This version includes a number of new features and bugfixes.

It also includes an API change that causes deprecation
warnings:

- BooleanQuery is now immutable and can be built using the
  BooleanQuery.Builder class

Instantiate instances of BooleanQuery with the new builder class
instead of with its constructor.

See the release notes for full details:

https://lucene.apache.org/core/5_3_0/changes/Changes.html

Change-Id: I5954b10017f2ff1531b036f953c6e4488e338f0e
This commit is contained in:
David Pursehouse 2015-09-01 19:25:13 +09:00
parent 53167f8095
commit 3ace71cbec
3 changed files with 18 additions and 18 deletions

View File

@ -82,11 +82,11 @@ public class QueryBuilder {
private Query or(Predicate<ChangeData> p)
throws QueryParseException {
try {
BooleanQuery q = new BooleanQuery();
BooleanQuery.Builder q = new BooleanQuery.Builder();
for (int i = 0; i < p.getChildCount(); i++) {
q.add(toQuery(p.getChild(i)), SHOULD);
}
return q;
return q.build();
} catch (BooleanQuery.TooManyClauses e) {
throw new QueryParseException("cannot create query for index: " + p, e);
}
@ -95,7 +95,7 @@ public class QueryBuilder {
private Query and(Predicate<ChangeData> p)
throws QueryParseException {
try {
BooleanQuery b = new BooleanQuery();
BooleanQuery.Builder b = new BooleanQuery.Builder();
List<Query> not = Lists.newArrayListWithCapacity(p.getChildCount());
for (int i = 0; i < p.getChildCount(); i++) {
Predicate<ChangeData> c = p.getChild(i);
@ -113,7 +113,7 @@ public class QueryBuilder {
for (Query q : not) {
b.add(q, MUST_NOT);
}
return b;
return b.build();
} catch (BooleanQuery.TooManyClauses e) {
throw new QueryParseException("cannot create query for index: " + p, e);
}
@ -127,10 +127,10 @@ public class QueryBuilder {
}
// Lucene does not support negation, start with all and subtract.
BooleanQuery q = new BooleanQuery();
q.add(new MatchAllDocsQuery(), MUST);
q.add(toQuery(n), MUST_NOT);
return q;
return new BooleanQuery.Builder()
.add(new MatchAllDocsQuery(), MUST)
.add(toQuery(n), MUST_NOT)
.build();
}
private Query fieldQuery(IndexPredicate<ChangeData> p)

View File

@ -107,16 +107,16 @@ public class ReviewerSuggestionCache {
List<String> segments = Splitter.on(' ').omitEmptyStrings().splitToList(
query.toLowerCase());
BooleanQuery q = new BooleanQuery();
BooleanQuery.Builder q = new BooleanQuery.Builder();
for (String field : ALL) {
BooleanQuery and = new BooleanQuery();
BooleanQuery.Builder and = new BooleanQuery.Builder();
for (String s : segments) {
and.add(new PrefixQuery(new Term(field, s)), Occur.MUST);
}
q.add(and, Occur.SHOULD);
q.add(and.build(), Occur.SHOULD);
}
TopDocs results = searcher.search(q, n);
TopDocs results = searcher.search(q.build(), n);
ScoreDoc[] hits = results.scoreDocs;
List<AccountInfo> result = new LinkedList<>();

View File

@ -1,6 +1,6 @@
include_defs('//lib/maven.defs')
VERSION = '5.2.1'
VERSION = '5.3.0'
# core and backward-codecs both provide
# META-INF/services/org.apache.lucene.codecs.Codec, so they must be merged.
@ -16,7 +16,7 @@ merge_maven_jars(
maven_jar(
name = 'core_jar',
id = 'org.apache.lucene:lucene-core:' + VERSION,
sha1 = 'a175590aa8b04e079eb1a136fd159f9163482ba4',
sha1 = '9e12bb7c39e964a544e3a23b9c8ffa9599d38f10',
license = 'Apache2.0',
exclude = [
'META-INF/LICENSE.txt',
@ -28,7 +28,7 @@ maven_jar(
maven_jar(
name = 'analyzers-common',
id = 'org.apache.lucene:lucene-analyzers-common:' + VERSION,
sha1 = '33b7cc17d5a7c939af6fe3f67563f4709926d7f5',
sha1 = '1502beac94cf437baff848ffbbb8f76172befa6b',
license = 'Apache2.0',
deps = [':core-and-backward-codecs'],
exclude = [
@ -40,7 +40,7 @@ maven_jar(
maven_jar(
name = 'backward-codecs_jar',
id = 'org.apache.lucene:lucene-backward-codecs:' + VERSION,
sha1 = '603d1f06b133449272799d698e5118db65e523ba',
sha1 = 'f654901e55fe56bdbe4be202767296929c2f8d9e',
license = 'Apache2.0',
deps = [':core_jar'],
exclude = [
@ -53,7 +53,7 @@ maven_jar(
maven_jar(
name = 'misc',
id = 'org.apache.lucene:lucene-misc:' + VERSION,
sha1 = 'be0a4f0ac06f0a2fa3689b4bf6cd1fe6847f9969',
sha1 = 'd03ce6d1bb8ab3926b3acc717418c474a49ade69',
license = 'Apache2.0',
deps = [':core-and-backward-codecs'],
exclude = [
@ -65,7 +65,7 @@ maven_jar(
maven_jar(
name = 'queryparser',
id = 'org.apache.lucene:lucene-queryparser:' + VERSION,
sha1 = '73be0a2d4ab3e6b574be1938bfb27f7f730f0ad9',
sha1 = '2c5e08580316c90b56a52e3cb686e1cf69db3f9e',
license = 'Apache2.0',
deps = [':core-and-backward-codecs'],
exclude = [