Skip to content

Commit

Permalink
remove or cutover all uses of now unsupported versions
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemccand committed Mar 2, 2016
1 parent c62ad7b commit 09aa951
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 296 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,7 @@ public ArabicAnalyzer(CharArraySet stopwords, CharArraySet stemExclusionSet){
protected TokenStreamComponents createComponents(String fieldName) {
final Tokenizer source = new StandardTokenizer();
TokenStream result = new LowerCaseFilter(source);
if (getVersion().onOrAfter(Version.LUCENE_5_4_0)) {
result = new DecimalDigitFilter(result);
}
result = new DecimalDigitFilter(result);
// the order here is important: the stopword list is not normalized!
result = new StopFilter(result, stopwords);
// TODO maybe we should make ArabicNormalization filter also KeywordAttribute aware?!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ protected TokenStreamComponents createComponents(String fieldName) {
TokenStream result = new StandardFilter(source);
result = new SoraniNormalizationFilter(result);
result = new LowerCaseFilter(result);
if (getVersion().onOrAfter(Version.LUCENE_5_4_0)) {
result = new DecimalDigitFilter(result);
}
result = new DecimalDigitFilter(result);
result = new StopFilter(result, stopwords);
if(!stemExclusionSet.isEmpty())
result = new SetKeywordMarkerFilter(result, stemExclusionSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ public PersianAnalyzer(CharArraySet stopwords){
protected TokenStreamComponents createComponents(String fieldName) {
final Tokenizer source = new StandardTokenizer();
TokenStream result = new LowerCaseFilter(source);
if (getVersion().onOrAfter(Version.LUCENE_5_4_0)) {
result = new DecimalDigitFilter(result);
}
result = new DecimalDigitFilter(result);
result = new ArabicNormalizationFilter(result);
/* additional persian-specific normalization */
result = new PersianNormalizationFilter(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,7 @@ public HindiAnalyzer() {
protected TokenStreamComponents createComponents(String fieldName) {
final Tokenizer source = new StandardTokenizer();
TokenStream result = new LowerCaseFilter(source);
if (getVersion().onOrAfter(Version.LUCENE_5_4_0)) {
result = new DecimalDigitFilter(result);
}
result = new DecimalDigitFilter(result);
if (!stemExclusionSet.isEmpty())
result = new SetKeywordMarkerFilter(result, stemExclusionSet);
result = new IndicNormalizationFilter(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ public ThaiAnalyzer(CharArraySet stopwords) {
protected TokenStreamComponents createComponents(String fieldName) {
final Tokenizer source = new ThaiTokenizer();
TokenStream result = new LowerCaseFilter(source);
if (getVersion().onOrAfter(Version.LUCENE_5_4_0)) {
result = new DecimalDigitFilter(result);
}
result = new DecimalDigitFilter(result);

result = new StopFilter(result, stopwords);
return new TokenStreamComponents(source, result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,6 @@ public void testDigits() throws Exception {
a.close();
}

/**
* test that we don't fold digits for back compat behavior
* @deprecated remove this test in lucene 7
*/
@Deprecated
public void testDigitsBackCompat() throws Exception {
ArabicAnalyzer a = new ArabicAnalyzer();
a.setVersion(Version.LUCENE_5_3_0);
checkOneTerm(a, "١٢٣٤", "١٢٣٤");
a.close();
}

/** blast some random strings through the analyzer */
public void testRandomStrings() throws Exception {
ArabicAnalyzer a = new ArabicAnalyzer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@ public void testDigits() throws Exception {
a.close();
}

/**
* test that we don't fold digits for back compat behavior
* @deprecated remove this test in lucene 7
*/
@Deprecated
public void testDigitsBackCompat() throws Exception {
SoraniAnalyzer a = new SoraniAnalyzer();
a.setVersion(Version.LUCENE_5_3_0);
checkOneTerm(a, "١٢٣٤", "١٢٣٤");
a.close();
}

/** blast some random strings through the analyzer */
public void testRandomStrings() throws Exception {
Analyzer a = new SoraniAnalyzer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testWhitespaceWithFolding() throws Exception {

public void testFactoryHtmlStripClassicFolding() throws Exception {
CustomAnalyzer a = CustomAnalyzer.builder()
.withDefaultMatchVersion(Version.LUCENE_5_0_0)
.withDefaultMatchVersion(Version.LUCENE_6_0_0)
.addCharFilter(HTMLStripCharFilterFactory.class)
.withTokenizer(ClassicTokenizerFactory.class)
.addTokenFilter(ASCIIFoldingFilterFactory.class, "preserveOriginal", "true")
Expand All @@ -114,7 +114,7 @@ public void testFactoryHtmlStripClassicFolding() throws Exception {
assertSame(LowerCaseFilterFactory.class, tokenFilters.get(1).getClass());
assertEquals(100, a.getPositionIncrementGap("dummy"));
assertEquals(1000, a.getOffsetGap("dummy"));
assertSame(Version.LUCENE_5_0_0, a.getVersion());
assertSame(Version.LUCENE_6_0_0, a.getVersion());

assertAnalyzesTo(a, "<p>foo bar</p> FOO BAR",
new String[] { "foo", "bar", "foo", "bar" },
Expand All @@ -127,7 +127,7 @@ public void testFactoryHtmlStripClassicFolding() throws Exception {

public void testHtmlStripClassicFolding() throws Exception {
CustomAnalyzer a = CustomAnalyzer.builder()
.withDefaultMatchVersion(Version.LUCENE_5_0_0)
.withDefaultMatchVersion(Version.LUCENE_6_0_0)
.addCharFilter("htmlstrip")
.withTokenizer("classic")
.addTokenFilter("asciifolding", "preserveOriginal", "true")
Expand All @@ -146,7 +146,7 @@ public void testHtmlStripClassicFolding() throws Exception {
assertSame(LowerCaseFilterFactory.class, tokenFilters.get(1).getClass());
assertEquals(100, a.getPositionIncrementGap("dummy"));
assertEquals(1000, a.getOffsetGap("dummy"));
assertSame(Version.LUCENE_5_0_0, a.getVersion());
assertSame(Version.LUCENE_6_0_0, a.getVersion());

assertAnalyzesTo(a, "<p>foo bar</p> FOO BAR",
new String[] { "foo", "bar", "foo", "bar" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,6 @@ public void testDigits() throws Exception {
a.close();
}

/**
* test that we don't fold digits for back compat behavior
* @deprecated remove this test in lucene 7
*/
@Deprecated
public void testDigitsBackCompat() throws Exception {
PersianAnalyzer a = new PersianAnalyzer();
a.setVersion(Version.LUCENE_5_3_0);
checkOneTerm(a, "۱۲۳۴", "۱۲۳۴");
a.close();
}

/** blast some random strings through the analyzer */
public void testRandomStrings() throws Exception {
PersianAnalyzer a = new PersianAnalyzer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@ public void testDigits() throws Exception {
a.close();
}

/**
* test that we don't fold digits for back compat behavior
* @deprecated remove this test in lucene 7
*/
@Deprecated
public void testDigitsBackCompat() throws Exception {
HindiAnalyzer a = new HindiAnalyzer();
a.setVersion(Version.LUCENE_5_3_0);
checkOneTerm(a, "१२३४", "१२३४");
a.close();
}

/** blast some random strings through the analyzer */
public void testRandomStrings() throws Exception {
Analyzer analyzer = new HindiAnalyzer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,6 @@ public void testDigits() throws Exception {
a.close();
}

/**
* test that we don't fold digits for back compat behavior
* @deprecated remove this test in lucene 7
*/
@Deprecated
public void testDigitsBackCompat() throws Exception {
ThaiAnalyzer a = new ThaiAnalyzer();
a.setVersion(Version.LUCENE_5_3_0);
checkOneTerm(a, "๑๒๓๔", "๑๒๓๔");
a.close();
}

public void testTwoSentences() throws Exception {
Analyzer analyzer = new ThaiAnalyzer(CharArraySet.EMPTY_SET);
assertAnalyzesTo(analyzer, "This is a test. การที่ได้ต้องแสดงว่างานดี",
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void testVersionsOneSegment() throws IOException {
Codec codec = Codec.getDefault();

SegmentInfos sis = new SegmentInfos();
SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_5_0_0, "_0", 1, false, Codec.getDefault(),
SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_6_0_0, "_0", 1, false, Codec.getDefault(),
Collections.<String,String>emptyMap(), id, Collections.<String,String>emptyMap());
info.setFiles(Collections.<String>emptySet());
codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT);
Expand All @@ -59,7 +59,7 @@ public void testVersionsOneSegment() throws IOException {
sis.add(commitInfo);
sis.commit(dir);
sis = SegmentInfos.readLatestCommit(dir);
assertEquals(Version.LUCENE_5_0_0, sis.getMinSegmentLuceneVersion());
assertEquals(Version.LUCENE_6_0_0, sis.getMinSegmentLuceneVersion());
assertEquals(Version.LATEST, sis.getCommitLuceneVersion());
dir.close();
}
Expand All @@ -72,14 +72,14 @@ public void testVersionsTwoSegments() throws IOException {
Codec codec = Codec.getDefault();

SegmentInfos sis = new SegmentInfos();
SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_5_0_0, "_0", 1, false, Codec.getDefault(),
SegmentInfo info = new SegmentInfo(dir, Version.LUCENE_6_0_0, "_0", 1, false, Codec.getDefault(),
Collections.<String,String>emptyMap(), id, Collections.<String,String>emptyMap());
info.setFiles(Collections.<String>emptySet());
codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT);
SegmentCommitInfo commitInfo = new SegmentCommitInfo(info, 0, -1, -1, -1);
sis.add(commitInfo);

info = new SegmentInfo(dir, Version.LUCENE_5_1_0, "_1", 1, false, Codec.getDefault(),
info = new SegmentInfo(dir, Version.LUCENE_6_0_0, "_1", 1, false, Codec.getDefault(),
Collections.<String,String>emptyMap(), id, Collections.<String,String>emptyMap());
info.setFiles(Collections.<String>emptySet());
codec.segmentInfoFormat().write(dir, info, IOContext.DEFAULT);
Expand All @@ -88,7 +88,7 @@ public void testVersionsTwoSegments() throws IOException {

sis.commit(dir);
sis = SegmentInfos.readLatestCommit(dir);
assertEquals(Version.LUCENE_5_0_0, sis.getMinSegmentLuceneVersion());
assertEquals(Version.LUCENE_6_0_0, sis.getMinSegmentLuceneVersion());
assertEquals(Version.LATEST, sis.getCommitLuceneVersion());
dir.close();
}
Expand Down
18 changes: 9 additions & 9 deletions lucene/core/src/test/org/apache/lucene/util/TestVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,25 @@ public void testOnOrAfter() throws Exception {
assertTrue("LATEST must be always onOrAfter("+v+")", Version.LATEST.onOrAfter(v));
}
}
assertTrue(Version.LUCENE_6_0_0.onOrAfter(Version.LUCENE_5_0_0));;
assertTrue(Version.LUCENE_7_0_0.onOrAfter(Version.LUCENE_6_0_0));;
}

public void testToString() {
assertEquals("5.0.0", Version.LUCENE_5_0_0.toString());
assertEquals("6.0.0", Version.LUCENE_6_0_0.toString());
assertEquals("7.0.0", Version.LUCENE_7_0_0.toString());
}

public void testParseLeniently() throws Exception {
assertEquals(Version.LUCENE_5_0_0, Version.parseLeniently("5.0"));
assertEquals(Version.LUCENE_5_0_0, Version.parseLeniently("5.0.0"));
assertEquals(Version.LUCENE_5_0_0, Version.parseLeniently("LUCENE_50"));
assertEquals(Version.LUCENE_5_0_0, Version.parseLeniently("LUCENE_5_0"));
assertEquals(Version.LUCENE_5_0_0, Version.parseLeniently("LUCENE_5_0_0"));
assertEquals(Version.LUCENE_6_0_0, Version.parseLeniently("6.0"));
assertEquals(Version.LUCENE_6_0_0, Version.parseLeniently("6.0.0"));
assertEquals(Version.LUCENE_6_0_0, Version.parseLeniently("LUCENE_60"));
assertEquals(Version.LUCENE_6_0_0, Version.parseLeniently("LUCENE_6_0"));
assertEquals(Version.LUCENE_6_0_0, Version.parseLeniently("LUCENE_6_0_0"));
assertEquals(Version.LUCENE_7_0_0, Version.parseLeniently("7.0"));
assertEquals(Version.LUCENE_7_0_0, Version.parseLeniently("7.0.0"));
assertEquals(Version.LUCENE_7_0_0, Version.parseLeniently("LUCENE_70"));
assertEquals(Version.LUCENE_7_0_0, Version.parseLeniently("LUCENE_7_0"));
assertEquals(Version.LUCENE_7_0_0, Version.parseLeniently("LUCENE_7_0_0"));
assertEquals(Version.LATEST, Version.parseLeniently("LATEST"));
assertEquals(Version.LATEST, Version.parseLeniently("latest"));
assertEquals(Version.LATEST, Version.parseLeniently("LUCENE_CURRENT"));
Expand Down Expand Up @@ -95,15 +95,15 @@ public void testParseLenientlyOnAllConstants() throws Exception {

public void testParse() throws Exception {
assertEquals(Version.LUCENE_6_0_0, Version.parse("6.0.0"));
assertEquals(Version.LUCENE_5_0_0, Version.parse("5.0.0"));
assertEquals(Version.LUCENE_7_0_0, Version.parse("7.0.0"));

// Version does not pass judgement on the major version:
assertEquals(1, Version.parse("1.0").major);
assertEquals(7, Version.parse("7.0.0").major);
}

public void testForwardsCompatibility() throws Exception {
assertTrue(Version.parse("5.10.20").onOrAfter(Version.LUCENE_5_0_0));
assertTrue(Version.parse("6.10.20").onOrAfter(Version.LUCENE_6_0_0));
}

public void testParseExceptions() {
Expand Down
Loading

0 comments on commit 09aa951

Please sign in to comment.