Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-1987: Remove rest of analysis deprecations (StandardAnalyzer, StopAnalyzer)

Uwe Schindler1ae5f89cfb30
diff --git a/CHANGES.txt b/CHANGES.txt
index 6a41c9c16bf..23f394930ab 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -77,8 +77,11 @@ API Changes
* LUCENE-1989: Generify CharArraySet. (Uwe Schindler)
-* LUCENE-1987: Rremove deprecations from analysis package and Token.
- Un-deprecate some ctors of Token, as they are still useful.
+* LUCENE-1987: Un-deprecate some ctors of Token, as they will not
+ be removed in 3.0 and are still useful. Also add some missing
+ o.a.l.util.Version constants for enabling invalid acronym
+ settings in StandardAnalyzer to be compatible with the coming
+ Lucene 3.0. Remove the rest of deprecated analysis methods/classes.
(Uwe Schindler)
* LUCENE-1945: All public classes that have a close() method now
diff --git a/common-build.xml b/common-build.xml
index 7c9c70d78b5..a84fed22ecb 100644
--- a/common-build.xml
+++ b/common-build.xml
@@ -42,7 +42,7 @@
<property name="Name" value="Lucene"/>
<property name="dev.version" value="3.0-dev"/>
<property name="version" value="${dev.version}"/>
- <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091018"/>
+ <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091021"/>
<property name="spec.version" value="${version}"/>
<property name="year" value="2000-${current.year}"/>
<property name="final.name" value="lucene-${name}-${version}"/>
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java
index 00a96e419b0..0d1447eab23 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java
@@ -64,7 +64,7 @@ public final class ArabicAnalyzer extends Analyzer {
/**
* Contains the stopwords used with the StopFilter.
*/
- private Set stoptable = new HashSet();
+ private final Set<?> stoptable;
/**
* The comment character in the stopwords file. All lines prefixed with this will be ignored
*/
@@ -119,15 +119,15 @@ public final class ArabicAnalyzer extends Analyzer {
/**
* Builds an analyzer with the given stop words.
*/
- public ArabicAnalyzer( String[] stopwords ) {
+ public ArabicAnalyzer( String... stopwords ) {
stoptable = StopFilter.makeStopSet( stopwords );
}
/**
* Builds an analyzer with the given stop words.
*/
- public ArabicAnalyzer( Hashtable stopwords ) {
- stoptable = new HashSet(stopwords.keySet());
+ public ArabicAnalyzer( Hashtable<?,?> stopwords ) {
+ stoptable = new HashSet( stopwords.keySet() );
}
/**
@@ -149,7 +149,7 @@ public final class ArabicAnalyzer extends Analyzer {
TokenStream result = new ArabicLetterTokenizer( reader );
result = new LowerCaseFilter(result);
// the order here is important: the stopword list is not normalized!
- result = new StopFilter( result, stoptable );
+ result = new StopFilter(false, result, stoptable );
result = new ArabicNormalizationFilter( result );
result = new ArabicStemFilter( result );
@@ -177,7 +177,7 @@ public final class ArabicAnalyzer extends Analyzer {
streams.source = new ArabicLetterTokenizer(reader);
streams.result = new LowerCaseFilter(streams.source);
// the order here is important: the stopword list is not normalized!
- streams.result = new StopFilter(streams.result, stoptable);
+ streams.result = new StopFilter(false, streams.result, stoptable);
streams.result = new ArabicNormalizationFilter(streams.result);
streams.result = new ArabicStemFilter(streams.result);
setPreviousTokenStream(streams);
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/BrazilianAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/BrazilianAnalyzer.java
index f0efada4f4e..93e983f0fd8 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/BrazilianAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/br/BrazilianAnalyzer.java
@@ -23,6 +23,7 @@ import java.io.Reader;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.Collections;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.LowerCaseFilter;
@@ -71,12 +72,12 @@ public final class BrazilianAnalyzer extends Analyzer {
/**
* Contains the stopwords used with the {@link StopFilter}.
*/
- private Set stoptable = new HashSet();
+ private Set stoptable = Collections.emptySet();
/**
* Contains words that should be indexed but not stemmed.
*/
- private Set excltable = new HashSet();
+ private Set excltable = Collections.emptySet();
/**
* Builds an analyzer with the default stop words ({@link #BRAZILIAN_STOP_WORDS}).
@@ -88,7 +89,7 @@ public final class BrazilianAnalyzer extends Analyzer {
/**
* Builds an analyzer with the given stop words.
*/
- public BrazilianAnalyzer( String[] stopwords ) {
+ public BrazilianAnalyzer( String... stopwords ) {
stoptable = StopFilter.makeStopSet( stopwords );
}
@@ -109,7 +110,7 @@ public final class BrazilianAnalyzer extends Analyzer {
/**
* Builds an exclusionlist from an array of Strings.
*/
- public void setStemExclusionTable( String[] exclusionlist ) {
+ public void setStemExclusionTable( String... exclusionlist ) {
excltable = StopFilter.makeStopSet( exclusionlist );
setPreviousTokenStream(null); // force a new stemmer to be created
}
@@ -139,7 +140,7 @@ public final class BrazilianAnalyzer extends Analyzer {
TokenStream result = new StandardTokenizer( reader );
result = new LowerCaseFilter( result );
result = new StandardFilter( result );
- result = new StopFilter( result, stoptable );
+ result = new StopFilter( false, result, stoptable );
result = new BrazilianStemFilter( result, excltable );
return result;
}
@@ -165,7 +166,7 @@ public final class BrazilianAnalyzer extends Analyzer {
streams.source = new StandardTokenizer(reader);
streams.result = new LowerCaseFilter(streams.source);
streams.result = new StandardFilter(streams.result);
- streams.result = new StopFilter(streams.result, stoptable);
+ streams.result = new StopFilter(false, streams.result, stoptable);
streams.result = new BrazilianStemFilter(streams.result, excltable);
setPreviousTokenStream(streams);
} else {
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java
index f5e871b5722..004a30a4f18 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java
@@ -55,7 +55,7 @@ public class CJKAnalyzer extends Analyzer {
/**
* stop word list
*/
- private Set stopTable;
+ private final Set stopTable;
//~ Constructors -----------------------------------------------------------
@@ -71,7 +71,7 @@ public class CJKAnalyzer extends Analyzer {
*
* @param stopWords stop word array
*/
- public CJKAnalyzer(String[] stopWords) {
+ public CJKAnalyzer(String... stopWords) {
stopTable = StopFilter.makeStopSet(stopWords);
}
@@ -86,7 +86,7 @@ public class CJKAnalyzer extends Analyzer {
* {@link StopFilter}
*/
public final TokenStream tokenStream(String fieldName, Reader reader) {
- return new StopFilter(new CJKTokenizer(reader), stopTable);
+ return new StopFilter(false, new CJKTokenizer(reader), stopTable);
}
private class SavedStreams {
@@ -109,7 +109,7 @@ public class CJKAnalyzer extends Analyzer {
if (streams == null) {
streams = new SavedStreams();
streams.source = new CJKTokenizer(reader);
- streams.result = new StopFilter(streams.source, stopTable);
+ streams.result = new StopFilter(false, streams.source, stopTable);
setPreviousTokenStream(streams);
} else {
streams.source.reset(reader);
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java
index 30b05345eed..da6ed17cd77 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java
@@ -29,6 +29,7 @@ import org.apache.lucene.analysis.standard.StandardTokenizer;
import java.io.*;
import java.util.HashSet;
import java.util.Set;
+import java.util.Collections;
/**
* {@link Analyzer} for Czech language.
@@ -79,7 +80,7 @@ public final class CzechAnalyzer extends Analyzer {
/**
* Builds an analyzer with the given stop words.
*/
- public CzechAnalyzer( String[] stopwords ) {
+ public CzechAnalyzer( String... stopwords ) {
stoptable = StopFilter.makeStopSet( stopwords );
}
@@ -107,7 +108,7 @@ public final class CzechAnalyzer extends Analyzer {
}
try {
// clear any previous table (if present)
- stoptable = new HashSet();
+ stoptable = Collections.emptySet();
InputStreamReader isr;
if (encoding == null)
@@ -115,16 +116,11 @@ public final class CzechAnalyzer extends Analyzer {
else
isr = new InputStreamReader(wordfile, encoding);
- LineNumberReader lnr = new LineNumberReader(isr);
- String word;
- while ( ( word = lnr.readLine() ) != null ) {
- stoptable.add(word);
- }
-
+ stoptable = WordlistLoader.getWordSet(isr);
} catch ( IOException e ) {
// clear any previous table (if present)
// TODO: throw IOException
- stoptable = new HashSet();
+ stoptable = Collections.emptySet();
}
}
@@ -138,7 +134,7 @@ public final class CzechAnalyzer extends Analyzer {
TokenStream result = new StandardTokenizer( reader );
result = new StandardFilter( result );
result = new LowerCaseFilter( result );
- result = new StopFilter( result, stoptable );
+ result = new StopFilter(false, result, stoptable );
return result;
}
@@ -162,7 +158,7 @@ public final class CzechAnalyzer extends Analyzer {
streams.source = new StandardTokenizer(reader);
streams.result = new StandardFilter(streams.source);
streams.result = new LowerCaseFilter(streams.result);
- streams.result = new StopFilter(streams.result, stoptable);
+ streams.result = new StopFilter(false, streams.result, stoptable);
setPreviousTokenStream(streams);
} else {
streams.source.reset(reader);
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java
index 72a5c78da85..b0941a189c4 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java
@@ -86,7 +86,7 @@ public class GermanAnalyzer extends Analyzer {
/**
* Builds an analyzer with the given stop words.
*/
- public GermanAnalyzer(String[] stopwords) {
+ public GermanAnalyzer(String... stopwords) {
stopSet = StopFilter.makeStopSet(stopwords);
setOverridesTokenStreamMethod(GermanAnalyzer.class);
}
@@ -142,7 +142,7 @@ public class GermanAnalyzer extends Analyzer {
TokenStream result = new StandardTokenizer(reader);
result = new StandardFilter(result);
result = new LowerCaseFilter(result);
- result = new StopFilter(result, stopSet);
+ result = new StopFilter(false, result, stopSet);
result = new GermanStemFilter(result, exclusionSet);
return result;
}
@@ -174,7 +174,7 @@ public class GermanAnalyzer extends Analyzer {
streams.source = new StandardTokenizer(reader);
streams.result = new StandardFilter(streams.source);
streams.result = new LowerCaseFilter(streams.result);
- streams.result = new StopFilter(streams.result, stopSet);
+ streams.result = new StopFilter(false, streams.result, stopSet);
streams.result = new GermanStemFilter(streams.result, exclusionSet);
setPreviousTokenStream(streams);
} else {
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java
index 9ca97323f48..0c1536982d5 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java
@@ -67,7 +67,7 @@ public final class GreekAnalyzer extends Analyzer
* Builds an analyzer with the given stop words.
* @param stopwords Array of stopwords to use.
*/
- public GreekAnalyzer(String [] stopwords)
+ public GreekAnalyzer(String... stopwords)
{
super();
stopSet = StopFilter.makeStopSet(stopwords);
@@ -92,7 +92,7 @@ public final class GreekAnalyzer extends Analyzer
{
TokenStream result = new StandardTokenizer(reader);
result = new GreekLowerCaseFilter(result);
- result = new StopFilter(result, stopSet);
+ result = new StopFilter(false, result, stopSet);
return result;
}
@@ -115,7 +115,7 @@ public final class GreekAnalyzer extends Analyzer
streams = new SavedStreams();
streams.source = new StandardTokenizer(reader);
streams.result = new GreekLowerCaseFilter(streams.source);
- streams.result = new StopFilter(streams.result, stopSet);
+ streams.result = new StopFilter(false, streams.result, stopSet);
setPreviousTokenStream(streams);
} else {
streams.source.reset(reader);
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/fr/FrenchAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/fr/FrenchAnalyzer.java
index 4e5c231e8ad..9d54fc50f52 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/fr/FrenchAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/fr/FrenchAnalyzer.java
@@ -92,7 +92,7 @@ public final class FrenchAnalyzer extends Analyzer {
/**
* Builds an analyzer with the given stop words.
*/
- public FrenchAnalyzer(String[] stopwords) {
+ public FrenchAnalyzer(String... stopwords) {
stoptable = StopFilter.makeStopSet(stopwords);
}
@@ -107,7 +107,7 @@ public final class FrenchAnalyzer extends Analyzer {
/**
* Builds an exclusionlist from an array of Strings.
*/
- public void setStemExclusionTable(String[] exclusionlist) {
+ public void setStemExclusionTable(String... exclusionlist) {
excltable = StopFilter.makeStopSet(exclusionlist);
setPreviousTokenStream(null); // force a new stemmer to be created
}
@@ -144,7 +144,7 @@ public final class FrenchAnalyzer extends Analyzer {
TokenStream result = new StandardTokenizer(reader);
result = new StandardFilter(result);
- result = new StopFilter(result, stoptable);
+ result = new StopFilter(false, result, stoptable);
result = new FrenchStemFilter(result, excltable);
// Convert to lowercase after stemming!
result = new LowerCaseFilter(result);
@@ -171,7 +171,7 @@ public final class FrenchAnalyzer extends Analyzer {
streams = new SavedStreams();
streams.source = new StandardTokenizer(reader);
streams.result = new StandardFilter(streams.source);
- streams.result = new StopFilter(streams.result, stoptable);
+ streams.result = new StopFilter(false, streams.result, stoptable);
streams.result = new FrenchStemFilter(streams.result, excltable);
// Convert to lowercase after stemming!
streams.result = new LowerCaseFilter(streams.result);
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java
index ae40d4fe72b..f56e91cd0f8 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/nl/DutchAnalyzer.java
@@ -94,7 +94,7 @@ public class DutchAnalyzer extends Analyzer {
*
* @param stopwords
*/
- public DutchAnalyzer(String[] stopwords) {
+ public DutchAnalyzer(String... stopwords) {
setOverridesTokenStreamMethod(DutchAnalyzer.class);
stoptable = StopFilter.makeStopSet(stopwords);
}
@@ -129,7 +129,7 @@ public class DutchAnalyzer extends Analyzer {
*
* @param exclusionlist
*/
- public void setStemExclusionTable(String[] exclusionlist) {
+ public void setStemExclusionTable(String... exclusionlist) {
excltable = StopFilter.makeStopSet(exclusionlist);
setPreviousTokenStream(null); // force a new stemmer to be created
}
@@ -181,7 +181,7 @@ public class DutchAnalyzer extends Analyzer {
public TokenStream tokenStream(String fieldName, Reader reader) {
TokenStream result = new StandardTokenizer(reader);
result = new StandardFilter(result);
- result = new StopFilter(result, stoptable);
+ result = new StopFilter(false, result, stoptable);
result = new DutchStemFilter(result, excltable, stemdict);
return result;
}
@@ -213,7 +213,7 @@ public class DutchAnalyzer extends Analyzer {
streams = new SavedStreams();
streams.source = new StandardTokenizer(reader);
streams.result = new StandardFilter(streams.source);
- streams.result = new StopFilter(streams.result, stoptable);
+ streams.result = new StopFilter(false, streams.result, stoptable);
streams.result = new DutchStemFilter(streams.result, excltable, stemdict);
setPreviousTokenStream(streams);
} else {
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
index 2a284dee557..6d0ab3890c6 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/query/QueryAutoStopWordAnalyzer.java
@@ -175,7 +175,7 @@ public class QueryAutoStopWordAnalyzer extends Analyzer {
}
HashSet stopWords = (HashSet) stopWordsPerField.get(fieldName);
if (stopWords != null) {
- result = new StopFilter(result, stopWords);
+ result = new StopFilter(false, result, stopWords);
}
return result;
}
@@ -217,7 +217,7 @@ public class QueryAutoStopWordAnalyzer extends Analyzer {
/* if there are any stopwords for the field, save the stopfilter */
HashSet stopWords = (HashSet) stopWordsPerField.get(fieldName);
if (stopWords != null)
- streams.withStopFilter = new StopFilter(streams.wrapped, stopWords);
+ streams.withStopFilter = new StopFilter(false, streams.wrapped, stopWords);
else
streams.withStopFilter = streams.wrapped;
@@ -238,7 +238,7 @@ public class QueryAutoStopWordAnalyzer extends Analyzer {
streams.wrapped = result;
HashSet stopWords = (HashSet) stopWordsPerField.get(fieldName);
if (stopWords != null)
- streams.withStopFilter = new StopFilter(streams.wrapped, stopWords);
+ streams.withStopFilter = new StopFilter(false, streams.wrapped, stopWords);
else
streams.withStopFilter = streams.wrapped;
}
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java
index 17e61db1b05..a706f137e98 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java
@@ -67,7 +67,7 @@ public final class RussianAnalyzer extends Analyzer
/**
* Builds an analyzer with the given stop words.
*/
- public RussianAnalyzer(String[] stopwords)
+ public RussianAnalyzer(String... stopwords)
{
super();
stopSet = StopFilter.makeStopSet(stopwords);
@@ -96,7 +96,7 @@ public final class RussianAnalyzer extends Analyzer
{
TokenStream result = new RussianLetterTokenizer(reader);
result = new LowerCaseFilter(result);
- result = new StopFilter(result, stopSet);
+ result = new StopFilter(false, result, stopSet);
result = new RussianStemFilter(result);
return result;
}
@@ -122,7 +122,7 @@ public final class RussianAnalyzer extends Analyzer
streams = new SavedStreams();
streams.source = new RussianLetterTokenizer(reader);
streams.result = new LowerCaseFilter(streams.source);
- streams.result = new StopFilter(streams.result, stopSet);
+ streams.result = new StopFilter(false, streams.result, stopSet);
streams.result = new RussianStemFilter(streams.result);
setPreviousTokenStream(streams);
} else {
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapper.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapper.java
index 2ac6ffec91a..89282f67ec8 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapper.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapper.java
@@ -23,6 +23,7 @@ import java.io.Reader;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
+import org.apache.lucene.util.Version;
/**
* A ShingleAnalyzerWrapper wraps a {@link ShingleFilter} around another {@link Analyzer}.
@@ -50,14 +51,17 @@ public class ShingleAnalyzerWrapper extends Analyzer {
/**
* Wraps {@link StandardAnalyzer}.
*/
- public ShingleAnalyzerWrapper() {
+ public ShingleAnalyzerWrapper(Version matchVersion) {
super();
- this.defaultAnalyzer = new StandardAnalyzer();
+ this.defaultAnalyzer = new StandardAnalyzer(matchVersion);
setOverridesTokenStreamMethod(ShingleAnalyzerWrapper.class);
}
- public ShingleAnalyzerWrapper(int nGramSize) {
- this();
+ /**
+ * Wraps {@link StandardAnalyzer}.
+ */
+ public ShingleAnalyzerWrapper(Version matchVersion, int nGramSize) {
+ this(matchVersion);
this.maxShingleSize = nGramSize;
}
diff --git a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/th/ThaiAnalyzer.java b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/th/ThaiAnalyzer.java
index a0d6ab4422f..d4b6937cba6 100644
--- a/contrib/analyzers/common/src/java/org/apache/lucene/analysis/th/ThaiAnalyzer.java
+++ b/contrib/analyzers/common/src/java/org/apache/lucene/analysis/th/ThaiAnalyzer.java
@@ -40,7 +40,7 @@ public class ThaiAnalyzer extends Analyzer {
TokenStream ts = new StandardTokenizer(reader);
ts = new StandardFilter(ts);
ts = new ThaiWordFilter(ts);
- ts = new StopFilter(ts, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
+ ts = new StopFilter(false, ts, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
return ts;
}
@@ -63,7 +63,7 @@ public class ThaiAnalyzer extends Analyzer {
streams.source = new StandardTokenizer(reader);
streams.result = new StandardFilter(streams.source);
streams.result = new ThaiWordFilter(streams.result);
- streams.result = new StopFilter(streams.result, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
+ streams.result = new StopFilter(false, streams.result, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
setPreviousTokenStream(streams);
} else {
streams.source.reset(reader);
diff --git a/contrib/analyzers/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java b/contrib/analyzers/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
index 15434eaa980..b05aa0bb55c 100644
--- a/contrib/analyzers/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
+++ b/contrib/analyzers/common/src/test/org/apache/lucene/analysis/shingle/ShingleAnalyzerWrapperTest.java
@@ -216,6 +216,10 @@ public class ShingleAnalyzerWrapperTest extends BaseTokenStreamTestCase {
* subclass that acts just like whitespace analyzer for testing
*/
private class ShingleWrapperSubclassAnalyzer extends ShingleAnalyzerWrapper {
+ public ShingleWrapperSubclassAnalyzer() {
+ super(org.apache.lucene.util.Version.LUCENE_CURRENT);
+ }
+
public TokenStream tokenStream(String fieldName, Reader reader) {
return new WhitespaceTokenizer(reader);
}
diff --git a/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java b/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java
index 8a689f0679c..f4a3003208a 100644
--- a/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java
+++ b/contrib/ant/src/java/org/apache/lucene/ant/IndexTask.java
@@ -27,6 +27,7 @@ import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.Vector;
+import java.lang.reflect.Constructor;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.SimpleAnalyzer;
@@ -43,6 +44,7 @@ import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DynamicConfigurator;
import org.apache.tools.ant.Project;
@@ -200,6 +202,17 @@ public class IndexTask extends Task {
handlerConfig = config;
}
+ private static final Analyzer createAnalyzer(String className) throws Exception{
+ final Class<? extends Analyzer> clazz = Class.forName(className).asSubclass(Analyzer.class);
+ try {
+ // first try to use a ctor with version parameter (needed for many new Analyzers that have no default one anymore
+ Constructor<? extends Analyzer> cnstr = clazz.getConstructor(Version.class);
+ return cnstr.newInstance(Version.LUCENE_CURRENT);
+ } catch (NoSuchMethodException nsme) {
+ // otherwise use default ctor
+ return clazz.newInstance();
+ }
+ }
/**
* Begins the indexing
@@ -214,14 +227,9 @@ public class IndexTask extends Task {
Class clazz = Class.forName(handlerClassName);
handler = (DocumentHandler) clazz.newInstance();
- clazz = Class.forName(analyzerClassName);
- analyzer = (Analyzer) clazz.newInstance();
- } catch (ClassNotFoundException cnfe) {
- throw new BuildException(cnfe);
- } catch (InstantiationException ie) {
- throw new BuildException(ie);
- } catch (IllegalAccessException iae) {
- throw new BuildException(iae);
+ analyzer = this.createAnalyzer(analyzerClassName);
+ } catch (Exception e) {
+ throw new BuildException(e);
}
log("Document handler = " + handler.getClass(), Project.MSG_VERBOSE);
diff --git a/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java b/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java
index 5c30e06dc11..6627e597964 100644
--- a/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java
+++ b/contrib/ant/src/test/org/apache/lucene/ant/IndexTaskTest.java
@@ -69,7 +69,7 @@ public class IndexTaskTest extends TestCase {
dir = FSDirectory.open(indexDir);
searcher = new IndexSearcher(dir, true);
- analyzer = new StopAnalyzer();
+ analyzer = new StopAnalyzer(false);
}
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
index b9e4b3704ba..615d7b84885 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/PerfRunData.java
@@ -30,6 +30,7 @@ import org.apache.lucene.benchmark.byTask.tasks.ReadTask;
import org.apache.lucene.benchmark.byTask.tasks.SearchTask;
import org.apache.lucene.benchmark.byTask.utils.Config;
import org.apache.lucene.benchmark.byTask.utils.FileUtils;
+import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.search.IndexSearcher;
@@ -76,8 +77,8 @@ public class PerfRunData {
public PerfRunData (Config config) throws Exception {
this.config = config;
// analyzer (default is standard analyzer)
- analyzer = (Analyzer) Class.forName(config.get("analyzer",
- "org.apache.lucene.analysis.standard.StandardAnalyzer")).newInstance();
+ analyzer = NewAnalyzerTask.createAnalyzer(config.get("analyzer",
+ "org.apache.lucene.analysis.standard.StandardAnalyzer"));
// doc maker
docMaker = (DocMaker) Class.forName(config.get("doc.maker",
"org.apache.lucene.benchmark.byTask.feeds.DocMaker")).newInstance();
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiQueryMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiQueryMaker.java
index a66a47af789..22fb558d743 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiQueryMaker.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/EnwikiQueryMaker.java
@@ -32,6 +32,7 @@ import org.apache.lucene.search.spans.SpanFirstQuery;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
+import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
/**
* A QueryMaker that uses common and uncommon actual Wikipedia queries for
@@ -122,8 +123,7 @@ public class EnwikiQueryMaker extends AbstractQueryMaker implements
protected Query[] prepareQueries() throws Exception {
// analyzer (default is standard analyzer)
- Analyzer anlzr = (Analyzer) Class.forName(
- config.get("analyzer", StandardAnalyzer.class.getName())).newInstance();
+ Analyzer anlzr = NewAnalyzerTask.createAnalyzer(config.get("analyzer", StandardAnalyzer.class.getName()));
List queryList = new ArrayList(20);
queryList.addAll(Arrays.asList(STANDARD_QUERIES));
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
index dc36f02cd00..4ed7af4f3ad 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/FileBasedQueryMaker.java
@@ -4,6 +4,7 @@ import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.Query;
+import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
import java.io.*;
import java.util.ArrayList;
@@ -44,8 +45,8 @@ public class FileBasedQueryMaker extends AbstractQueryMaker implements QueryMake
protected Query[] prepareQueries() throws Exception {
- Analyzer anlzr = (Analyzer) Class.forName(config.get("analyzer",
- "org.apache.lucene.analysis.standard.StandardAnalyzer")).newInstance();
+ Analyzer anlzr = NewAnalyzerTask.createAnalyzer(config.get("analyzer",
+ "org.apache.lucene.analysis.standard.StandardAnalyzer"));
String defaultField = config.get("file.query.maker.default.field", DocMaker.BODY_FIELD);
QueryParser qp = new QueryParser(defaultField, anlzr);
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersQueryMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersQueryMaker.java
index 9591ebb6b86..47d8fddfb69 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersQueryMaker.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ReutersQueryMaker.java
@@ -26,6 +26,7 @@ import org.apache.lucene.search.spans.SpanFirstQuery;
import org.apache.lucene.search.spans.SpanNearQuery;
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
+import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
import java.util.ArrayList;
import java.util.Arrays;
@@ -102,8 +103,8 @@ public class ReutersQueryMaker extends AbstractQueryMaker implements QueryMaker
protected Query[] prepareQueries() throws Exception {
// analyzer (default is standard analyzer)
- Analyzer anlzr= (Analyzer) Class.forName(config.get("analyzer",
- "org.apache.lucene.analysis.standard.StandardAnalyzer")).newInstance();
+ Analyzer anlzr= NewAnalyzerTask.createAnalyzer(config.get("analyzer",
+ "org.apache.lucene.analysis.standard.StandardAnalyzer"));
List queryList = new ArrayList(20);
queryList.addAll(Arrays.asList(STANDARD_QUERIES));
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SimpleQueryMaker.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SimpleQueryMaker.java
index 77d1812fa8a..5503009ba76 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SimpleQueryMaker.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/SimpleQueryMaker.java
@@ -24,6 +24,7 @@ import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.benchmark.byTask.tasks.NewAnalyzerTask;
import java.util.ArrayList;
@@ -42,8 +43,8 @@ public class SimpleQueryMaker extends AbstractQueryMaker implements QueryMaker {
*/
protected Query[] prepareQueries() throws Exception {
// analyzer (default is standard analyzer)
- Analyzer anlzr= (Analyzer) Class.forName(config.get("analyzer",
- "org.apache.lucene.analysis.standard.StandardAnalyzer")).newInstance();
+ Analyzer anlzr= NewAnalyzerTask.createAnalyzer(config.get("analyzer",
+ "org.apache.lucene.analysis.standard.StandardAnalyzer"));
QueryParser qp = new QueryParser(DocMaker.BODY_FIELD,anlzr);
ArrayList qq = new ArrayList();
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NewAnalyzerTask.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NewAnalyzerTask.java
index 5dff943bb7a..587cf95606f 100644
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NewAnalyzerTask.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/NewAnalyzerTask.java
@@ -17,11 +17,13 @@ package org.apache.lucene.benchmark.byTask.tasks;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.benchmark.byTask.PerfRunData;
+import org.apache.lucene.util.Version;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
+import java.lang.reflect.Constructor;
/**
* Create a new {@link org.apache.lucene.analysis.Analyzer} and set it it in the getRunData() for use by all future tasks.
@@ -35,6 +37,18 @@ public class NewAnalyzerTask extends PerfTask {
super(runData);
analyzerClassNames = new ArrayList();
}
+
+ public static final Analyzer createAnalyzer(String className) throws Exception{
+ final Class<? extends Analyzer> clazz = Class.forName(className).asSubclass(Analyzer.class);
+ try {
+ // first try to use a ctor with version parameter (needed for many new Analyzers that have no default one anymore
+ Constructor<? extends Analyzer> cnstr = clazz.getConstructor(Version.class);
+ return cnstr.newInstance(Version.LUCENE_CURRENT);
+ } catch (NoSuchMethodException nsme) {
+ // otherwise use default ctor
+ return clazz.newInstance();
+ }
+ }
public int doLogic() throws IOException {
String className = null;
@@ -52,7 +66,7 @@ public class NewAnalyzerTask extends PerfTask {
{
className = "org.apache.lucene.analysis." + className;
}
- getRunData().setAnalyzer((Analyzer) Class.forName(className).newInstance());
+ getRunData().setAnalyzer(createAnalyzer(className));
System.out.println("Changed Analyzer to: " + className);
} catch (Exception e) {
throw new RuntimeException("Error creating Analyzer: " + className, e);
diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java
index 30e4a39fcf5..6c357c83b4c 100755
--- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java
+++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/quality/utils/SimpleQQParser.java
@@ -22,6 +22,7 @@ import org.apache.lucene.benchmark.quality.QualityQueryParser;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.search.Query;
+import org.apache.lucene.util.Version;
/**
* Simplistic quality query parser. A Lucene query is created by passing
@@ -49,7 +50,7 @@ public class SimpleQQParser implements QualityQueryParser {
public Query parse(QualityQuery qq) throws ParseException {
QueryParser qp = (QueryParser) queryParser.get();
if (qp==null) {
- qp = new QueryParser(indexField, new StandardAnalyzer());
+ qp = new QueryParser(indexField, new StandardAnalyzer(Version.LUCENE_CURRENT));
queryParser.set(qp);
}
return qp.parse(qq.getValue(qqName));
diff --git a/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java b/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
index 0ba7ec83bfc..92e115b3515 100644
--- a/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
+++ b/contrib/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
@@ -83,13 +83,16 @@ import org.w3c.dom.NodeList;
*
*/
public class HighlighterTest extends BaseTokenStreamTestCase implements Formatter {
+ // TODO: change to CURRENT, does not work because posIncr:
+ static final Version TEST_VERSION = Version.LUCENE_24;
+
private IndexReader reader;
static final String FIELD_NAME = "contents";
private Query query;
RAMDirectory ramDir;
public IndexSearcher searcher = null;
int numHighlights = 0;
- Analyzer analyzer = new StandardAnalyzer();
+ final Analyzer analyzer = new StandardAnalyzer(TEST_VERSION);
TopDocs hits;
String[] texts = {
@@ -140,7 +143,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
String s1 = "I call our world Flatland, not because we call it so,";
- QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer(Version.LUCENE_CURRENT));
+ QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
// Verify that a query against the default field results in text being
// highlighted
@@ -172,7 +175,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
*/
private static String highlightField(Query query, String fieldName, String text)
throws IOException, InvalidTokenOffsetsException {
- TokenStream tokenStream = new StandardAnalyzer(Version.LUCENE_CURRENT).tokenStream(fieldName, new StringReader(text));
+ TokenStream tokenStream = new StandardAnalyzer(TEST_VERSION).tokenStream(fieldName, new StringReader(text));
// Assuming "<B>", "</B>" used to highlight
SimpleHTMLFormatter formatter = new SimpleHTMLFormatter();
QueryScorer scorer = new QueryScorer(query, fieldName, FIELD_NAME);
@@ -542,7 +545,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// Need to explicitly set the QueryParser property to use TermRangeQuery
// rather
// than RangeFilters
- QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+ QueryParser parser = new QueryParser(FIELD_NAME, analyzer);
parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
query = parser.parse(queryString);
doSearching(query);
@@ -693,7 +696,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
hg.setTextFragmenter(new NullFragmenter());
String match = null;
- match = hg.getBestFragment(new StandardAnalyzer(), "data", "help me [54-65]");
+ match = hg.getBestFragment(analyzer, "data", "help me [54-65]");
assertEquals("<B>help</B> me [54-65]", match);
}
@@ -1004,13 +1007,13 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
sb.append(stopWords.iterator().next());
}
SimpleHTMLFormatter fm = new SimpleHTMLFormatter();
- Highlighter hg = getHighlighter(query, "data", new StandardAnalyzer(stopWords).tokenStream(
+ Highlighter hg = getHighlighter(query, "data", new StandardAnalyzer(TEST_VERSION, stopWords).tokenStream(
"data", new StringReader(sb.toString())), fm);// new Highlighter(fm,
// new
// QueryTermScorer(query));
hg.setTextFragmenter(new NullFragmenter());
hg.setMaxDocBytesToAnalyze(100);
- match = hg.getBestFragment(new StandardAnalyzer(stopWords), "data", sb.toString());
+ match = hg.getBestFragment(new StandardAnalyzer(TEST_VERSION, stopWords), "data", sb.toString());
assertTrue("Matched text should be no more than 100 chars in length ", match.length() < hg
.getMaxDocBytesToAnalyze());
@@ -1021,7 +1024,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// + whitespace)
sb.append(" ");
sb.append(goodWord);
- match = hg.getBestFragment(new StandardAnalyzer(stopWords), "data", sb.toString());
+ match = hg.getBestFragment(new StandardAnalyzer(TEST_VERSION, stopWords), "data", sb.toString());
assertTrue("Matched text should be no more than 100 chars in length ", match.length() < hg
.getMaxDocBytesToAnalyze());
}
@@ -1041,11 +1044,11 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
String text = "this is a text with searchterm in it";
SimpleHTMLFormatter fm = new SimpleHTMLFormatter();
- Highlighter hg = getHighlighter(query, "text", new StandardAnalyzer(
+ Highlighter hg = getHighlighter(query, "text", new StandardAnalyzer(TEST_VERSION,
stopWords).tokenStream("text", new StringReader(text)), fm);
hg.setTextFragmenter(new NullFragmenter());
hg.setMaxDocCharsToAnalyze(36);
- String match = hg.getBestFragment(new StandardAnalyzer(stopWords), "text", text);
+ String match = hg.getBestFragment(new StandardAnalyzer(TEST_VERSION, stopWords), "text", text);
assertTrue(
"Matched text should contain remainder of text after highlighted query ",
match.endsWith("in it"));
@@ -1061,7 +1064,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
numHighlights = 0;
// test to show how rewritten query can still be used
searcher = new IndexSearcher(ramDir, true);
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(TEST_VERSION);
QueryParser parser = new QueryParser(FIELD_NAME, analyzer);
Query query = parser.parse("JF? or Kenned*");
@@ -1074,7 +1077,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// highlighted text
// QueryHighlightExtractor highlighter = new
// QueryHighlightExtractor(this,
- // query, new StandardAnalyzer());
+ // query, new StandardAnalyzer(TEST_VERSION));
int maxNumFragmentsRequired = 3;
@@ -1173,7 +1176,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
public void testMultiSearcher() throws Exception {
// setup index 1
RAMDirectory ramDir1 = new RAMDirectory();
- IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter writer1 = new IndexWriter(ramDir1, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
Document d = new Document();
Field f = new Field(FIELD_NAME, "multiOne", Field.Store.YES, Field.Index.ANALYZED);
d.add(f);
@@ -1184,7 +1187,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
// setup index 2
RAMDirectory ramDir2 = new RAMDirectory();
- IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter writer2 = new IndexWriter(ramDir2, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
d = new Document();
f = new Field(FIELD_NAME, "multiTwo", Field.Store.YES, Field.Index.ANALYZED);
d.add(f);
@@ -1197,14 +1200,14 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
searchers[0] = new IndexSearcher(ramDir1, true);
searchers[1] = new IndexSearcher(ramDir2, true);
MultiSearcher multiSearcher = new MultiSearcher(searchers);
- QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+ QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
query = parser.parse("multi*");
System.out.println("Searching for: " + query.toString(FIELD_NAME));
// at this point the multisearcher calls combine(query[])
hits = multiSearcher.search(query, null, 1000);
- // query = QueryParser.parse("multi*", FIELD_NAME, new StandardAnalyzer());
+ // query = QueryParser.parse("multi*", FIELD_NAME, new StandardAnalyzer(TEST_VERSION));
Query expandedQueries[] = new Query[2];
expandedQueries[0] = query.rewrite(reader1);
expandedQueries[1] = query.rewrite(reader2);
@@ -1527,7 +1530,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
}
public void doSearching(String queryString) throws Exception {
- QueryParser parser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+ QueryParser parser = new QueryParser(FIELD_NAME, analyzer);
parser.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
query = parser.parse(queryString);
doSearching(query);
@@ -1564,7 +1567,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
protected void setUp() throws Exception {
super.setUp();
ramDir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(ramDir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter writer = new IndexWriter(ramDir, new StandardAnalyzer(TEST_VERSION), true, IndexWriter.MaxFieldLength.UNLIMITED);
for (int i = 0; i < texts.length; i++) {
addDoc(writer, texts[i]);
}
diff --git a/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java b/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
index 9e53ebc7513..84f73ec345a 100644
--- a/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
+++ b/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
@@ -63,7 +63,7 @@ public class TestIndicesEquals extends TestCase {
RAMDirectory dir = new RAMDirectory();
// create dir data
- IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
for (int i = 0; i < 20; i++) {
Document document = new Document();
assembleDocument(document, i);
@@ -87,7 +87,7 @@ public class TestIndicesEquals extends TestCase {
InstantiatedIndex ii = new InstantiatedIndex();
// create dir data
- IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter indexWriter = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
for (int i = 0; i < 500; i++) {
Document document = new Document();
assembleDocument(document, i);
@@ -96,7 +96,7 @@ public class TestIndicesEquals extends TestCase {
indexWriter.close();
// test ii writer
- InstantiatedIndexWriter instantiatedIndexWriter = ii.indexWriterFactory(new StandardAnalyzer(), true);
+ InstantiatedIndexWriter instantiatedIndexWriter = ii.indexWriterFactory(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true);
for (int i = 0; i < 500; i++) {
Document document = new Document();
assembleDocument(document, i);
diff --git a/contrib/lucli/src/java/lucli/LuceneMethods.java b/contrib/lucli/src/java/lucli/LuceneMethods.java
index 169439ddf6d..9b20452d309 100644
--- a/contrib/lucli/src/java/lucli/LuceneMethods.java
+++ b/contrib/lucli/src/java/lucli/LuceneMethods.java
@@ -57,6 +57,7 @@ import org.apache.lucene.search.ScoreDoc;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
/**
* Various methods that interact with Lucene and provide info about the
@@ -80,18 +81,18 @@ class LuceneMethods {
}
private Analyzer createAnalyzer() {
- if (analyzerClassFQN == null) return new StandardAnalyzer();
+ if (analyzerClassFQN == null) return new StandardAnalyzer(Version.LUCENE_CURRENT);
try {
Class aClass = Class.forName(analyzerClassFQN);
Object obj = aClass.newInstance();
if (!(obj instanceof Analyzer)) {
message("Given class is not an Analyzer: " + analyzerClassFQN);
- return new StandardAnalyzer();
+ return new StandardAnalyzer(Version.LUCENE_CURRENT);
}
return (Analyzer)obj;
} catch (Exception e) {
message("Unable to use Analyzer " + analyzerClassFQN);
- return new StandardAnalyzer();
+ return new StandardAnalyzer(Version.LUCENE_CURRENT);
}
}
diff --git a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
index e0408710ce8..f3dc007c01d 100644
--- a/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
+++ b/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
@@ -277,8 +277,8 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
Analyzer[] analyzers = new Analyzer[] {
new SimpleAnalyzer(),
- new StopAnalyzer(),
- new StandardAnalyzer(),
+ new StopAnalyzer(true),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
PatternAnalyzer.DEFAULT_ANALYZER,
// new WhitespaceAnalyzer(),
// new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, false, null),
diff --git a/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java b/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
index 399ad86cc28..f8a15990e03 100644
--- a/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
+++ b/contrib/misc/src/test/org/apache/lucene/index/TestTermVectorAccessor.java
@@ -6,6 +6,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
import java.util.Collections;
/*
@@ -29,7 +30,7 @@ public class TestTermVectorAccessor extends TestCase {
public void test() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(Collections.EMPTY_SET), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(Version.LUCENE_CURRENT, Collections.emptySet()), true, IndexWriter.MaxFieldLength.UNLIMITED);
Document doc;
diff --git a/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java b/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
index 1271c97fb3b..63f06031ab2 100644
--- a/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
+++ b/contrib/misc/src/test/org/apache/lucene/queryParser/complexPhrase/TestComplexPhraseQuery.java
@@ -36,7 +36,7 @@ import org.apache.lucene.store.RAMDirectory;
public class TestComplexPhraseQuery extends TestCase {
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
DocData docsContent[] = { new DocData("john smith", "1"),
new DocData("johathon smith", "2"),
diff --git a/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java b/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
index 741f079a180..dd01aaa87d3 100644
--- a/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
+++ b/contrib/misc/src/test/org/apache/lucene/queryParser/precedence/TestPrecedenceQueryParser.java
@@ -44,6 +44,7 @@ import java.util.Arrays;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.HashSet;
+import java.util.Collections;
public class TestPrecedenceQueryParser extends LocalizedTestCase {
@@ -233,7 +234,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
assertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null,
"+(title:dog title:cat) -author:\"bob dole\"");
- PrecedenceQueryParser qp = new PrecedenceQueryParser("field", new StandardAnalyzer());
+ PrecedenceQueryParser qp = new PrecedenceQueryParser("field", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
// make sure OR is the default:
assertEquals(PrecedenceQueryParser.OR_OPERATOR, qp.getDefaultOperator());
qp.setDefaultOperator(PrecedenceQueryParser.AND_OPERATOR);
@@ -267,7 +268,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new StandardAnalyzer();
+ Analyzer a = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -505,7 +506,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
public void testBoost()
throws Exception {
- StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(new String[]{"on"});
+ StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.singleton("on"));
PrecedenceQueryParser qp = new PrecedenceQueryParser("field", oneStopAnalyzer);
Query q = qp.parse("on^1.0");
assertNotNull(q);
@@ -518,7 +519,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
q = qp.parse("\"on\"^1.0");
assertNotNull(q);
- q = getParser(new StandardAnalyzer()).parse("the^3");
+ q = getParser(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT)).parse("the^3");
assertNotNull(q);
}
diff --git a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java
index 125e73e4632..16bfe916dfe 100644
--- a/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java
+++ b/contrib/queries/src/java/org/apache/lucene/search/similar/MoreLikeThis.java
@@ -49,6 +49,7 @@ import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopDocs;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.util.PriorityQueue;
+import org.apache.lucene.util.Version;
/**
@@ -162,7 +163,7 @@ public final class MoreLikeThis {
* Default analyzer to parse source doc with.
* @see #getAnalyzer
*/
- public static final Analyzer DEFAULT_ANALYZER = new StandardAnalyzer();
+ public static final Analyzer DEFAULT_ANALYZER = new StandardAnalyzer(Version.LUCENE_CURRENT);
/**
* Ignore terms with less than this frequency in the source doc.
diff --git a/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java b/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
index cf9473797bb..1c824b244c0 100644
--- a/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
+++ b/contrib/queries/src/test/org/apache/lucene/search/DuplicateFilterTest.java
@@ -42,7 +42,7 @@ public class DuplicateFilterTest extends TestCase
protected void setUp() throws Exception
{
directory = new RAMDirectory();
- IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
//Add series of docs with filterable fields : url, text and dates flags
addDoc(writer, "http://lucene.apache.org", "lucene 1.4.3 available", "20040101");
diff --git a/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java b/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
index da69c249d15..b8c689fdbd2 100644
--- a/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
+++ b/contrib/queries/src/test/org/apache/lucene/search/similar/TestMoreLikeThis.java
@@ -43,7 +43,7 @@ public class TestMoreLikeThis extends LuceneTestCase {
protected void setUp() throws Exception {
directory = new RAMDirectory();
- IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(),
+ IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
true, MaxFieldLength.UNLIMITED);
// Add series of docs with specific information for MoreLikeThis
diff --git a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
index 8e2d9f57d6c..0537f024c73 100644
--- a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
+++ b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQPHelper.java
@@ -83,7 +83,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
String[] fields = { "b", "t" };
StandardQueryParser mfqp = new StandardQueryParser();
mfqp.setMultiFields(fields);
- mfqp.setAnalyzer(new StandardAnalyzer());
+ mfqp.setAnalyzer(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query q = mfqp.parse("one", null);
assertEquals("b:one t:one", q.toString());
@@ -153,7 +153,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
StandardQueryParser mfqp = new StandardQueryParser();
mfqp.setMultiFields(fields);
mfqp.setFieldsBoost(boosts);
- mfqp.setAnalyzer(new StandardAnalyzer());
+ mfqp.setAnalyzer(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
// Check for simple
Query q = mfqp.parse("one", null);
@@ -181,24 +181,24 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
public void testStaticMethod1() throws QueryNodeException {
String[] fields = { "b", "t" };
String[] queries = { "one", "two" };
- Query q = QueryParserUtil.parse(queries, fields, new StandardAnalyzer());
+ Query q = QueryParserUtil.parse(queries, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one t:two", q.toString());
String[] queries2 = { "+one", "+two" };
- q = QueryParserUtil.parse(queries2, fields, new StandardAnalyzer());
+ q = QueryParserUtil.parse(queries2, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(+b:one) (+t:two)", q.toString());
String[] queries3 = { "one", "+two" };
- q = QueryParserUtil.parse(queries3, fields, new StandardAnalyzer());
+ q = QueryParserUtil.parse(queries3, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one (+t:two)", q.toString());
String[] queries4 = { "one +more", "+two" };
- q = QueryParserUtil.parse(queries4, fields, new StandardAnalyzer());
+ q = QueryParserUtil.parse(queries4, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(b:one +b:more) (+t:two)", q.toString());
String[] queries5 = { "blah" };
try {
- q = QueryParserUtil.parse(queries5, fields, new StandardAnalyzer());
+ q = QueryParserUtil.parse(queries5, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -222,15 +222,15 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT };
Query q = QueryParserUtil.parse("one", fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:one", q.toString());
- q = QueryParserUtil.parse("one two", fields, flags, new StandardAnalyzer());
+ q = QueryParserUtil.parse("one two", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
- q = QueryParserUtil.parse("blah", fields, flags2, new StandardAnalyzer());
+ q = QueryParserUtil.parse("blah", fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -243,19 +243,19 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
BooleanClause.Occur.MUST_NOT };
StandardQueryParser parser = new StandardQueryParser();
parser.setMultiFields(fields);
- parser.setAnalyzer(new StandardAnalyzer());
+ parser.setAnalyzer(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query q = QueryParserUtil.parse("one", fields, flags,
- new StandardAnalyzer());// , fields, flags, new
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));// , fields, flags, new
// StandardAnalyzer());
assertEquals("+b:one -t:one", q.toString());
- q = QueryParserUtil.parse("one two", fields, flags, new StandardAnalyzer());
+ q = QueryParserUtil.parse("one two", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
- q = QueryParserUtil.parse("blah", fields, flags2, new StandardAnalyzer());
+ q = QueryParserUtil.parse("blah", fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -268,13 +268,13 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT, BooleanClause.Occur.SHOULD };
Query q = QueryParserUtil.parse(queries, fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+f1:one -f2:two f3:three", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
q = QueryParserUtil
- .parse(queries, fields, flags2, new StandardAnalyzer());
+ .parse(queries, fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -287,13 +287,13 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT };
Query q = QueryParserUtil.parse(queries, fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:two", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
q = QueryParserUtil
- .parse(queries, fields, flags2, new StandardAnalyzer());
+ .parse(queries, fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -319,7 +319,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
}
public void testStopWordSearching() throws Exception {
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
Directory ramDir = new RAMDirectory();
IndexWriter iw = new IndexWriter(ramDir, analyzer, true,
IndexWriter.MaxFieldLength.LIMITED);
@@ -345,7 +345,7 @@ public class TestMultiFieldQPHelper extends LuceneTestCase {
* Return empty tokens for field "f1".
*/
private static class AnalyzerReturningNull extends Analyzer {
- StandardAnalyzer stdAnalyzer = new StandardAnalyzer();
+ StandardAnalyzer stdAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
public AnalyzerReturningNull() {
}
diff --git a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
index fb1df119880..8cc0633e4d7 100644
--- a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
+++ b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestMultiFieldQueryParserWrapper.java
@@ -78,7 +78,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
public void testSimple() throws Exception {
String[] fields = { "b", "t" };
MultiFieldQueryParserWrapper mfqp = new MultiFieldQueryParserWrapper(
- fields, new StandardAnalyzer());
+ fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query q = mfqp.parse("one");
assertEquals("b:one t:one", q.toString());
@@ -146,7 +146,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
boosts.put("t", Float.valueOf(10));
String[] fields = { "b", "t" };
MultiFieldQueryParserWrapper mfqp = new MultiFieldQueryParserWrapper(
- fields, new StandardAnalyzer(), boosts);
+ fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), boosts);
// Check for simple
Query q = mfqp.parse("one");
@@ -175,28 +175,28 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
String[] fields = { "b", "t" };
String[] queries = { "one", "two" };
Query q = MultiFieldQueryParserWrapper.parse(queries, fields,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one t:two", q.toString());
String[] queries2 = { "+one", "+two" };
q = MultiFieldQueryParserWrapper.parse(queries2, fields,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(+b:one) (+t:two)", q.toString());
String[] queries3 = { "one", "+two" };
q = MultiFieldQueryParserWrapper.parse(queries3, fields,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one (+t:two)", q.toString());
String[] queries4 = { "one +more", "+two" };
q = MultiFieldQueryParserWrapper.parse(queries4, fields,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(b:one +b:more) (+t:two)", q.toString());
String[] queries5 = { "blah" };
try {
q = MultiFieldQueryParserWrapper.parse(queries5, fields,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -220,17 +220,17 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT };
Query q = MultiFieldQueryParserWrapper.parse("one", fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:one", q.toString());
q = MultiFieldQueryParserWrapper.parse("one two", fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
q = MultiFieldQueryParserWrapper.parse("blah", fields, flags2,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -244,20 +244,20 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT };
MultiFieldQueryParserWrapper parser = new MultiFieldQueryParserWrapper(
- fields, new StandardAnalyzer());
+ fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query q = MultiFieldQueryParserWrapper.parse("one", fields, flags,
- new StandardAnalyzer());// , fields, flags, new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));// , fields, flags, new StandardAnalyzer());
assertEquals("+b:one -t:one", q.toString());
q = MultiFieldQueryParserWrapper.parse("one two", fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
q = MultiFieldQueryParserWrapper.parse("blah", fields, flags2,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -270,13 +270,13 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT, BooleanClause.Occur.SHOULD };
Query q = MultiFieldQueryParserWrapper.parse(queries, fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+f1:one -f2:two f3:three", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
q = MultiFieldQueryParserWrapper.parse(queries, fields, flags2,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -289,13 +289,13 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
BooleanClause.Occur[] flags = { BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT };
Query q = MultiFieldQueryParserWrapper.parse(queries, fields, flags,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:two", q.toString());
try {
BooleanClause.Occur[] flags2 = { BooleanClause.Occur.MUST };
q = MultiFieldQueryParserWrapper.parse(queries, fields, flags2,
- new StandardAnalyzer());
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch (IllegalArgumentException e) {
// expected exception, array length differs
@@ -319,7 +319,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
}
public void testStopWordSearching() throws Exception {
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
Directory ramDir = new RAMDirectory();
IndexWriter iw = new IndexWriter(ramDir, analyzer, true,
IndexWriter.MaxFieldLength.LIMITED);
@@ -343,7 +343,7 @@ public class TestMultiFieldQueryParserWrapper extends LuceneTestCase {
* Return empty tokens for field "f1".
*/
private static class AnalyzerReturningNull extends Analyzer {
- StandardAnalyzer stdAnalyzer = new StandardAnalyzer();
+ StandardAnalyzer stdAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
public AnalyzerReturningNull() {
}
diff --git a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
index 41ed8f7d01f..77bf6122b1f 100644
--- a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
+++ b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
@@ -30,6 +30,7 @@ import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Collections;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.KeywordAnalyzer;
@@ -77,6 +78,7 @@ import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LocalizedTestCase;
+import org.apache.lucene.util.Version;
/**
* This test case is a copy of the core Lucene query parser test, it was adapted
@@ -410,7 +412,7 @@ public class TestQPHelper extends LocalizedTestCase {
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new StandardAnalyzer();
+ Analyzer a = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -896,8 +898,7 @@ public class TestQPHelper extends LocalizedTestCase {
}
public void testBoost() throws Exception {
- StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(
- new String[] { "on" });
+ StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(Version.LUCENE_CURRENT, Collections.singleton("on"));
StandardQueryParser qp = new StandardQueryParser();
qp.setAnalyzer(oneStopAnalyzer);
@@ -913,7 +914,7 @@ public class TestQPHelper extends LocalizedTestCase {
assertNotNull(q);
StandardQueryParser qp2 = new StandardQueryParser();
- qp2.setAnalyzer(new StandardAnalyzer());
+ qp2.setAnalyzer(new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
q = qp2.parse("the^3", "field");
// "the" is a stop word so the result is an empty query:
@@ -1069,7 +1070,7 @@ public class TestQPHelper extends LocalizedTestCase {
public void testStopwords() throws Exception {
StandardQueryParser qp = new StandardQueryParser();
qp.setAnalyzer(
- new StopAnalyzer(new String[] { "the", "foo" }));
+ new StopAnalyzer(StopFilter.makeStopSet("the", "foo" ), true));
Query result = qp.parse("a:the OR a:foo", "a");
assertNotNull("result is null and it shouldn't be", result);
@@ -1090,31 +1091,24 @@ public class TestQPHelper extends LocalizedTestCase {
}
public void testPositionIncrement() throws Exception {
- boolean dflt = StopFilter.getEnablePositionIncrementsDefault();
- StopFilter.setEnablePositionIncrementsDefault(true);
- try {
- StandardQueryParser qp = new StandardQueryParser();
- qp.setAnalyzer(
- new StopAnalyzer(new String[] { "the", "in", "are", "this" }));
-
- qp.setEnablePositionIncrements(true);
-
- String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
- // 0 2 5 7 8
- int expectedPositions[] = { 1, 3, 4, 6, 9 };
- PhraseQuery pq = (PhraseQuery) qp.parse(qtxt, "a");
- // System.out.println("Query text: "+qtxt);
- // System.out.println("Result: "+pq);
- Term t[] = pq.getTerms();
- int pos[] = pq.getPositions();
- for (int i = 0; i < t.length; i++) {
- // System.out.println(i+". "+t[i]+" pos: "+pos[i]);
- assertEquals("term " + i + " = " + t[i] + " has wrong term-position!",
- expectedPositions[i], pos[i]);
- }
-
- } finally {
- StopFilter.setEnablePositionIncrementsDefault(dflt);
+ StandardQueryParser qp = new StandardQueryParser();
+ qp.setAnalyzer(
+ new StopAnalyzer(StopFilter.makeStopSet("the", "in", "are", "this" ), true));
+
+ qp.setEnablePositionIncrements(true);
+
+ String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
+ // 0 2 5 7 8
+ int expectedPositions[] = { 1, 3, 4, 6, 9 };
+ PhraseQuery pq = (PhraseQuery) qp.parse(qtxt, "a");
+ // System.out.println("Query text: "+qtxt);
+ // System.out.println("Result: "+pq);
+ Term t[] = pq.getTerms();
+ int pos[] = pq.getPositions();
+ for (int i = 0; i < t.length; i++) {
+ // System.out.println(i+". "+t[i]+" pos: "+pos[i]);
+ assertEquals("term " + i + " = " + t[i] + " has wrong term-position!",
+ expectedPositions[i], pos[i]);
}
}
diff --git a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
index abe29001b3b..f5430faf807 100644
--- a/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
+++ b/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQueryParserWrapper.java
@@ -28,6 +28,7 @@ import java.util.GregorianCalendar;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
+import java.util.Collections;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.KeywordAnalyzer;
@@ -72,6 +73,7 @@ import org.apache.lucene.search.TermRangeQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LocalizedTestCase;
+import org.apache.lucene.util.Version;
/**
* This test case is a copy of the core Lucene query parser test, it was adapted
@@ -375,7 +377,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
"+(title:dog title:cat) -author:\"bob dole\"");
QueryParserWrapper qp = new QueryParserWrapper("field",
- new StandardAnalyzer());
+ new StandardAnalyzer(Version.LUCENE_CURRENT));
// make sure OR is the default:
assertEquals(QueryParserWrapper.OR_OPERATOR, qp.getDefaultOperator());
qp.setDefaultOperator(QueryParserWrapper.AND_OPERATOR);
@@ -406,7 +408,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new StandardAnalyzer();
+ Analyzer a = new StandardAnalyzer(Version.LUCENE_CURRENT);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -882,8 +884,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
}
public void testBoost() throws Exception {
- StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(
- new String[] { "on" });
+ StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(Version.LUCENE_CURRENT, Collections.singleton("on"));
QueryParserWrapper qp = new QueryParserWrapper("field", oneStopAnalyzer);
Query q = qp.parse("on^1.0");
assertNotNull(q);
@@ -897,7 +898,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
assertNotNull(q);
QueryParserWrapper qp2 = new QueryParserWrapper("field",
- new StandardAnalyzer());
+ new StandardAnalyzer(Version.LUCENE_CURRENT));
q = qp2.parse("the^3");
// "the" is a stop word so the result is an empty query:
assertNotNull(q);
@@ -1047,8 +1048,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
}
public void testStopwords() throws Exception {
- QueryParserWrapper qp = new QueryParserWrapper("a", new StopAnalyzer(
- new String[] { "the", "foo" }));
+ QueryParserWrapper qp = new QueryParserWrapper("a", new StopAnalyzer(StopFilter.makeStopSet("the", "foo"), false));
Query result = qp.parse("a:the OR a:foo");
assertNotNull("result is null and it shouldn't be", result);
assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
@@ -1067,28 +1067,20 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
}
public void testPositionIncrement() throws Exception {
- boolean dflt = StopFilter.getEnablePositionIncrementsDefault();
- StopFilter.setEnablePositionIncrementsDefault(true);
- try {
- QueryParserWrapper qp = new QueryParserWrapper("a", new StopAnalyzer(
- new String[] { "the", "in", "are", "this" }));
- qp.setEnablePositionIncrements(true);
- String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
- // 0 2 5 7 8
- int expectedPositions[] = { 1, 3, 4, 6, 9 };
- PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
- // System.out.println("Query text: "+qtxt);
- // System.out.println("Result: "+pq);
- Term t[] = pq.getTerms();
- int pos[] = pq.getPositions();
- for (int i = 0; i < t.length; i++) {
- // System.out.println(i+". "+t[i]+" pos: "+pos[i]);
- assertEquals("term " + i + " = " + t[i] + " has wrong term-position!",
- expectedPositions[i], pos[i]);
- }
-
- } finally {
- StopFilter.setEnablePositionIncrementsDefault(dflt);
+ QueryParserWrapper qp = new QueryParserWrapper("a", new StopAnalyzer(StopFilter.makeStopSet("the", "in", "are", "this"), true));
+ qp.setEnablePositionIncrements(true);
+ String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
+ // 0 2 5 7 8
+ int expectedPositions[] = { 1, 3, 4, 6, 9 };
+ PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
+ // System.out.println("Query text: "+qtxt);
+ // System.out.println("Result: "+pq);
+ Term t[] = pq.getTerms();
+ int pos[] = pq.getPositions();
+ for (int i = 0; i < t.length; i++) {
+ // System.out.println(i+". "+t[i]+" pos: "+pos[i]);
+ assertEquals("term " + i + " = " + t[i] + " has wrong term-position!",
+ expectedPositions[i], pos[i]);
}
}
diff --git a/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java b/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
index 4f945ac23d2..f8469f8ffe5 100644
--- a/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
+++ b/contrib/regex/src/test/org/apache/lucene/search/regex/TestSpanRegexQuery.java
@@ -109,14 +109,14 @@ public class TestSpanRegexQuery extends TestCase {
Field.Index.ANALYZED_NO_NORMS));
// creating first index writer
- IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(),
+ IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
true, IndexWriter.MaxFieldLength.LIMITED);
writerA.addDocument(lDoc);
writerA.optimize();
writerA.close();
// creating second index writer
- IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(),
+ IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
true, IndexWriter.MaxFieldLength.LIMITED);
writerB.addDocument(lDoc2);
writerB.optimize();
diff --git a/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java b/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java
index 882e77e7b50..e9ba5595059 100644
--- a/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java
+++ b/contrib/snowball/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java
@@ -55,7 +55,7 @@ public class SnowballAnalyzer extends Analyzer {
result = new StandardFilter(result);
result = new LowerCaseFilter(result);
if (stopSet != null)
- result = new StopFilter(result, stopSet);
+ result = new StopFilter(false, result, stopSet);
result = new SnowballFilter(result, name);
return result;
}
@@ -84,7 +84,7 @@ public class SnowballAnalyzer extends Analyzer {
streams.result = new StandardFilter(streams.source);
streams.result = new LowerCaseFilter(streams.result);
if (stopSet != null)
- streams.result = new StopFilter(streams.result, stopSet);
+ streams.result = new StopFilter(false, streams.result, stopSet);
streams.result = new SnowballFilter(streams.result, name);
setPreviousTokenStream(streams);
} else {
diff --git a/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java b/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java
index 7a72179bfb4..b57ff10983c 100755
--- a/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java
+++ b/contrib/wordnet/src/java/org/apache/lucene/wordnet/SynExpand.java
@@ -42,6 +42,7 @@ import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Searcher;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
/**
@@ -77,7 +78,7 @@ public final class SynExpand {
String query = args[1];
String field = "contents";
- Query q = expand( query, searcher, new StandardAnalyzer(), field, 0.9f);
+ Query q = expand( query, searcher, new StandardAnalyzer(Version.LUCENE_CURRENT), field, 0.9f);
System.out.println( "Query: " + q.toString( field));
@@ -112,7 +113,7 @@ public final class SynExpand {
final Set already = new HashSet(); // avoid dups
List top = new LinkedList(); // needs to be separately listed..
final String field = ( f == null) ? "contents" : f;
- if ( a == null) a = new StandardAnalyzer();
+ if ( a == null) a = new StandardAnalyzer(Version.LUCENE_CURRENT);
// [1] Parse query into separate words so that when we expand we can avoid dups
TokenStream ts = a.tokenStream( field, new StringReader( query));
diff --git a/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java b/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java
index 7742f8b6cda..2d08b818cb0 100644
--- a/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java
+++ b/contrib/wordnet/src/java/org/apache/lucene/wordnet/Syns2Index.java
@@ -36,6 +36,7 @@ import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.store.FSDirectory;
+import org.apache.lucene.util.Version;
/**
* Convert the prolog file wn_s.pl from the <a href="http://www.cogsci.princeton.edu/2.0/WNprolog-2.0.tar.gz">WordNet prolog download</a>
@@ -88,7 +89,7 @@ public class Syns2Index
/**
*
*/
- private static final Analyzer ana = new StandardAnalyzer();
+ private static final Analyzer ana = new StandardAnalyzer(Version.LUCENE_CURRENT);
/**
* Takes arg of prolog file name and index directory.
diff --git a/contrib/xml-query-parser/src/demo/java/org/apache/lucene/xmlparser/webdemo/FormBasedXmlQueryDemo.java b/contrib/xml-query-parser/src/demo/java/org/apache/lucene/xmlparser/webdemo/FormBasedXmlQueryDemo.java
index a55aab4035a..4eea93ec9ad 100644
--- a/contrib/xml-query-parser/src/demo/java/org/apache/lucene/xmlparser/webdemo/FormBasedXmlQueryDemo.java
+++ b/contrib/xml-query-parser/src/demo/java/org/apache/lucene/xmlparser/webdemo/FormBasedXmlQueryDemo.java
@@ -51,7 +51,7 @@ public class FormBasedXmlQueryDemo extends HttpServlet {
private QueryTemplateManager queryTemplateManager;
private CorePlusExtensionsParser xmlParser;
private IndexSearcher searcher;
- private Analyzer analyzer=new StandardAnalyzer();
+ private Analyzer analyzer=new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
public void init(ServletConfig config) throws ServletException {
super.init(config);
diff --git a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
index f2521080f44..33df0c64bc3 100644
--- a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
+++ b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestParser.java
@@ -39,7 +39,8 @@ public class TestParser extends TestCase {
CoreParser builder;
static Directory dir;
- Analyzer analyzer=new StandardAnalyzer();
+ // TODO: change to CURRENT and rewrite test (this needs to set QueryParser.enablePositionIncrements, too, for work with CURRENT):
+ Analyzer analyzer=new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_24);
IndexReader reader;
private IndexSearcher searcher;
diff --git a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
index ff4aa422aee..dd967e6daeb 100644
--- a/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
+++ b/contrib/xml-query-parser/src/test/org/apache/lucene/xmlparser/TestQueryTemplateManager.java
@@ -42,7 +42,7 @@ import org.xml.sax.SAXException;
public class TestQueryTemplateManager extends TestCase {
CoreParser builder;
- Analyzer analyzer=new StandardAnalyzer();
+ Analyzer analyzer=new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
private IndexSearcher searcher;
//A collection of documents' field values for use in our tests
diff --git a/src/java/org/apache/lucene/analysis/Analyzer.java b/src/java/org/apache/lucene/analysis/Analyzer.java
index db29bff15b5..297c8d1e4dc 100644
--- a/src/java/org/apache/lucene/analysis/Analyzer.java
+++ b/src/java/org/apache/lucene/analysis/Analyzer.java
@@ -84,25 +84,18 @@ public abstract class Analyzer implements Closeable {
}
}
- protected boolean overridesTokenStreamMethod;
+ /** @deprecated */
+ protected boolean overridesTokenStreamMethod = false;
/** @deprecated This is only present to preserve
* back-compat of classes that subclass a core analyzer
* and override tokenStream but not reusableTokenStream */
- protected void setOverridesTokenStreamMethod(Class baseClass) {
-
- final Class[] params = new Class[2];
- params[0] = String.class;
- params[1] = Reader.class;
-
+ protected void setOverridesTokenStreamMethod(Class<? extends Analyzer> baseClass) {
try {
- Method m = this.getClass().getMethod("tokenStream", params);
- if (m != null) {
- overridesTokenStreamMethod = m.getDeclaringClass() != baseClass;
- } else {
- overridesTokenStreamMethod = false;
- }
+ Method m = this.getClass().getMethod("tokenStream", String.class, Reader.class);
+ overridesTokenStreamMethod = m.getDeclaringClass() != baseClass;
} catch (NoSuchMethodException nsme) {
+ // cannot happen, as baseClass is subclass of Analyzer through generics
overridesTokenStreamMethod = false;
}
}
@@ -121,8 +114,7 @@ public abstract class Analyzer implements Closeable {
* @param fieldName Fieldable name being indexed.
* @return position increment gap, added to the next token emitted from {@link #tokenStream(String,Reader)}
*/
- public int getPositionIncrementGap(String fieldName)
- {
+ public int getPositionIncrementGap(String fieldName) {
return 0;
}
diff --git a/src/java/org/apache/lucene/analysis/StopAnalyzer.java b/src/java/org/apache/lucene/analysis/StopAnalyzer.java
index 42a84f2aa0c..4b3e0b909ac 100644
--- a/src/java/org/apache/lucene/analysis/StopAnalyzer.java
+++ b/src/java/org/apache/lucene/analysis/StopAnalyzer.java
@@ -22,106 +22,47 @@ import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;
import java.util.Set;
+import java.util.List;
/** Filters {@link LetterTokenizer} with {@link LowerCaseFilter} and {@link StopFilter}. */
public final class StopAnalyzer extends Analyzer {
- private final Set/*<String>*/ stopWords;
- // @deprecated
- private final boolean useDefaultStopPositionIncrement;
+ private final Set<?> stopWords;
private final boolean enablePositionIncrements;
-
- /** An array containing some common English words that are not usually useful
- for searching.
- @deprecated Use {@link #ENGLISH_STOP_WORDS_SET} instead */
- public static final String[] ENGLISH_STOP_WORDS = {
- "a", "an", "and", "are", "as", "at", "be", "but", "by",
- "for", "if", "in", "into", "is", "it",
- "no", "not", "of", "on", "or", "such",
- "that", "the", "their", "then", "there", "these",
- "they", "this", "to", "was", "will", "with"
- };
/** An unmodifiable set containing some common English words that are not usually useful
for searching.*/
- public static final Set/*<String>*/ ENGLISH_STOP_WORDS_SET;
+ public static final Set<?> ENGLISH_STOP_WORDS_SET;
static {
- final String[] stopWords = new String[]{
- "a", "an", "and", "are", "as", "at", "be", "but", "by",
- "for", "if", "in", "into", "is", "it",
- "no", "not", "of", "on", "or", "such",
- "that", "the", "their", "then", "there", "these",
- "they", "this", "to", "was", "will", "with"
- };
- final CharArraySet stopSet = new CharArraySet(stopWords.length, false);
- stopSet.addAll(Arrays.asList(stopWords));
- ENGLISH_STOP_WORDS_SET = CharArraySet.unmodifiableSet(stopSet);
+ final List<String> stopWords = Arrays.asList(
+ "a", "an", "and", "are", "as", "at", "be", "but", "by",
+ "for", "if", "in", "into", "is", "it",
+ "no", "not", "of", "on", "or", "such",
+ "that", "the", "their", "then", "there", "these",
+ "they", "this", "to", "was", "will", "with"
+ );
+ final CharArraySet stopSet = new CharArraySet(stopWords.size(), false);
+ stopSet.addAll(stopWords);
+ ENGLISH_STOP_WORDS_SET = CharArraySet.unmodifiableSet(stopSet);
}
/** Builds an analyzer which removes words in
- * ENGLISH_STOP_WORDS.
- * @deprecated Use {@link #StopAnalyzer(boolean)} instead */
- public StopAnalyzer() {
- stopWords = ENGLISH_STOP_WORDS_SET;
- useDefaultStopPositionIncrement = true;
- enablePositionIncrements = false;
- }
-
- /** Builds an analyzer which removes words in
- * ENGLISH_STOP_WORDS.
+ * {@link #ENGLISH_STOP_WORDS}.
* @param enablePositionIncrements See {@link
* StopFilter#setEnablePositionIncrements} */
public StopAnalyzer(boolean enablePositionIncrements) {
stopWords = ENGLISH_STOP_WORDS_SET;
this.enablePositionIncrements = enablePositionIncrements;
- useDefaultStopPositionIncrement = false;
- }
-
- /** Builds an analyzer with the stop words from the given set.
- * @deprecated Use {@link #StopAnalyzer(Set, boolean)} instead */
- public StopAnalyzer(Set stopWords) {
- this.stopWords = stopWords;
- useDefaultStopPositionIncrement = true;
- enablePositionIncrements = false;
}
/** Builds an analyzer with the stop words from the given set.
* @param stopWords Set of stop words
* @param enablePositionIncrements See {@link
* StopFilter#setEnablePositionIncrements} */
- public StopAnalyzer(Set stopWords, boolean enablePositionIncrements) {
+ public StopAnalyzer(Set<?> stopWords, boolean enablePositionIncrements) {
this.stopWords = stopWords;
this.enablePositionIncrements = enablePositionIncrements;
- useDefaultStopPositionIncrement = false;
- }
-
- /** Builds an analyzer which removes words in the provided array.
- * @deprecated Use {@link #StopAnalyzer(Set, boolean)} instead */
- public StopAnalyzer(String[] stopWords) {
- this.stopWords = StopFilter.makeStopSet(stopWords);
- useDefaultStopPositionIncrement = true;
- enablePositionIncrements = false;
- }
-
- /** Builds an analyzer which removes words in the provided array.
- * @param stopWords Array of stop words
- * @param enablePositionIncrements See {@link
- * StopFilter#setEnablePositionIncrements}
- * @deprecated Use {@link #StopAnalyzer(Set, boolean)} instead*/
- public StopAnalyzer(String[] stopWords, boolean enablePositionIncrements) {
- this.stopWords = StopFilter.makeStopSet(stopWords);
- this.enablePositionIncrements = enablePositionIncrements;
- useDefaultStopPositionIncrement = false;
- }
-
- /** Builds an analyzer with the stop words from the given file.
- * @see WordlistLoader#getWordSet(File)
- * @deprecated Use {@link #StopAnalyzer(File, boolean)} instead */
- public StopAnalyzer(File stopwordsFile) throws IOException {
- stopWords = WordlistLoader.getWordSet(stopwordsFile);
- useDefaultStopPositionIncrement = true;
- enablePositionIncrements = false;
}
/** Builds an analyzer with the stop words from the given file.
@@ -132,17 +73,6 @@ public final class StopAnalyzer extends Analyzer {
public StopAnalyzer(File stopwordsFile, boolean enablePositionIncrements) throws IOException {
stopWords = WordlistLoader.getWordSet(stopwordsFile);
this.enablePositionIncrements = enablePositionIncrements;
- useDefaultStopPositionIncrement = false;
- }
-
- /** Builds an analyzer with the stop words from the given reader.
- * @see WordlistLoader#getWordSet(Reader)
- * @deprecated Use {@link #StopAnalyzer(Reader, boolean)} instead
- */
- public StopAnalyzer(Reader stopwords) throws IOException {
- stopWords = WordlistLoader.getWordSet(stopwords);
- useDefaultStopPositionIncrement = true;
- enablePositionIncrements = false;
}
/** Builds an analyzer with the stop words from the given reader.
@@ -153,16 +83,11 @@ public final class StopAnalyzer extends Analyzer {
public StopAnalyzer(Reader stopwords, boolean enablePositionIncrements) throws IOException {
stopWords = WordlistLoader.getWordSet(stopwords);
this.enablePositionIncrements = enablePositionIncrements;
- useDefaultStopPositionIncrement = false;
}
/** Filters LowerCaseTokenizer with StopFilter. */
public TokenStream tokenStream(String fieldName, Reader reader) {
- if (useDefaultStopPositionIncrement) {
- return new StopFilter(new LowerCaseTokenizer(reader), stopWords);
- } else {
- return new StopFilter(enablePositionIncrements, new LowerCaseTokenizer(reader), stopWords);
- }
+ return new StopFilter(enablePositionIncrements, new LowerCaseTokenizer(reader), stopWords);
}
/** Filters LowerCaseTokenizer with StopFilter. */
@@ -175,11 +100,7 @@ public final class StopAnalyzer extends Analyzer {
if (streams == null) {
streams = new SavedStreams();
streams.source = new LowerCaseTokenizer(reader);
- if (useDefaultStopPositionIncrement) {
- streams.result = new StopFilter(streams.source, stopWords);
- } else {
- streams.result = new StopFilter(enablePositionIncrements, streams.source, stopWords);
- }
+ streams.result = new StopFilter(enablePositionIncrements, streams.source, stopWords);
setPreviousTokenStream(streams);
} else
streams.source.reset(reader);
diff --git a/src/java/org/apache/lucene/analysis/StopFilter.java b/src/java/org/apache/lucene/analysis/StopFilter.java
index 2377175d32f..0259df50d86 100644
--- a/src/java/org/apache/lucene/analysis/StopFilter.java
+++ b/src/java/org/apache/lucene/analysis/StopFilter.java
@@ -32,82 +32,11 @@ import org.apache.lucene.queryParser.QueryParser; // for javadoc
public final class StopFilter extends TokenFilter {
- // deprecated
- private static boolean ENABLE_POSITION_INCREMENTS_DEFAULT = false;
-
private final CharArraySet stopWords;
- private boolean enablePositionIncrements = ENABLE_POSITION_INCREMENTS_DEFAULT;
+ private boolean enablePositionIncrements = false;
private TermAttribute termAtt;
private PositionIncrementAttribute posIncrAtt;
-
- /**
- * Construct a token stream filtering the given input.
- * @deprecated Use {@link #StopFilter(boolean, TokenStream, String[])} instead
- */
- public StopFilter(TokenStream input, String [] stopWords)
- {
- this(ENABLE_POSITION_INCREMENTS_DEFAULT, input, stopWords, false);
- }
-
- /**
- * Construct a token stream filtering the given input.
- * @param enablePositionIncrements true if token positions should record the removed stop words
- * @param input input TokenStream
- * @param stopWords array of stop words
- * @deprecated Use {@link #StopFilter(boolean, TokenStream, Set)} instead.
- */
- public StopFilter(boolean enablePositionIncrements, TokenStream input, String [] stopWords)
- {
- this(enablePositionIncrements, input, stopWords, false);
- }
-
- /**
- * Constructs a filter which removes words from the input
- * TokenStream that are named in the array of words.
- * @deprecated Use {@link #StopFilter(boolean, TokenStream, String[], boolean)} instead
- */
- public StopFilter(TokenStream in, String[] stopWords, boolean ignoreCase) {
- this(ENABLE_POSITION_INCREMENTS_DEFAULT, in, stopWords, ignoreCase);
- }
-
- /**
- * Constructs a filter which removes words from the input
- * TokenStream that are named in the array of words.
- * @param enablePositionIncrements true if token positions should record the removed stop words
- * @param in input TokenStream
- * @param stopWords array of stop words
- * @param ignoreCase true if case is ignored
- * @deprecated Use {@link #StopFilter(boolean, TokenStream, Set, boolean)} instead.
- */
- public StopFilter(boolean enablePositionIncrements, TokenStream in, String[] stopWords, boolean ignoreCase) {
- super(in);
- this.stopWords = (CharArraySet)makeStopSet(stopWords, ignoreCase);
- this.enablePositionIncrements = enablePositionIncrements;
- init();
- }
-
-
- /**
- * Construct a token stream filtering the given input.
- * If <code>stopWords</code> is an instance of {@link CharArraySet} (true if
- * <code>makeStopSet()</code> was used to construct the set) it will be directly used
- * and <code>ignoreCase</code> will be ignored since <code>CharArraySet</code>
- * directly controls case sensitivity.
- * <p/>
- * If <code>stopWords</code> is not an instance of {@link CharArraySet},
- * a new CharArraySet will be constructed and <code>ignoreCase</code> will be
- * used to specify the case sensitivity of that set.
- *
- * @param input
- * @param stopWords The set of Stop Words.
- * @param ignoreCase -Ignore case when stopping.
- * @deprecated Use {@link #StopFilter(boolean, TokenStream, Set, boolean)} instead
- */
- public StopFilter(TokenStream input, Set stopWords, boolean ignoreCase)
- {
- this(ENABLE_POSITION_INCREMENTS_DEFAULT, input, stopWords, ignoreCase);
- }
/**
* Construct a token stream filtering the given input.
@@ -122,10 +51,11 @@ public final class StopFilter extends TokenFilter {
*
* @param enablePositionIncrements true if token positions should record the removed stop words
* @param input Input TokenStream
- * @param stopWords The set of Stop Words.
+ * @param stopWords A Set of Strings or char[] or any other toString()-able set representing the stopwords
+ * @param ignoreCase if true, all words are lower cased first
* @param ignoreCase -Ignore case when stopping.
*/
- public StopFilter(boolean enablePositionIncrements, TokenStream input, Set stopWords, boolean ignoreCase)
+ public StopFilter(boolean enablePositionIncrements, TokenStream input, Set<?> stopWords, boolean ignoreCase)
{
super(input);
if (stopWords instanceof CharArraySet) {
@@ -135,18 +65,8 @@ public final class StopFilter extends TokenFilter {
this.stopWords.addAll(stopWords);
}
this.enablePositionIncrements = enablePositionIncrements;
- init();
- }
-
- /**
- * Constructs a filter which removes words from the input
- * TokenStream that are named in the Set.
- *
- * @see #makeStopSet(java.lang.String[])
- * @deprecated Use {@link #StopFilter(boolean, TokenStream, Set)} instead
- */
- public StopFilter(TokenStream in, Set stopWords) {
- this(ENABLE_POSITION_INCREMENTS_DEFAULT, in, stopWords, false);
+ termAtt = addAttribute(TermAttribute.class);
+ posIncrAtt = addAttribute(PositionIncrementAttribute.class);
}
/**
@@ -155,17 +75,12 @@ public final class StopFilter extends TokenFilter {
*
* @param enablePositionIncrements true if token positions should record the removed stop words
* @param in Input stream
- * @param stopWords The set of Stop Words.
+ * @param stopWords A Set of Strings or char[] or any other toString()-able set representing the stopwords
* @see #makeStopSet(java.lang.String[])
*/
- public StopFilter(boolean enablePositionIncrements, TokenStream in, Set stopWords) {
+ public StopFilter(boolean enablePositionIncrements, TokenStream in, Set<?> stopWords) {
this(enablePositionIncrements, in, stopWords, false);
}
-
- public void init() {
- termAtt = addAttribute(TermAttribute.class);
- posIncrAtt = addAttribute(PositionIncrementAttribute.class);
- }
/**
* Builds a Set from an array of stop words,
@@ -175,7 +90,7 @@ public final class StopFilter extends TokenFilter {
*
* @see #makeStopSet(java.lang.String[], boolean) passing false to ignoreCase
*/
- public static final Set makeStopSet(String[] stopWords) {
+ public static final Set<Object> makeStopSet(String... stopWords) {
return makeStopSet(stopWords, false);
}
@@ -184,10 +99,11 @@ public final class StopFilter extends TokenFilter {
* appropriate for passing into the StopFilter constructor.
* This permits this stopWords construction to be cached once when
* an Analyzer is constructed.
- *
+ * @param stopWords A List of Strings or char[] or any other toString()-able list representing the stopwords
+ * @return A Set ({@link CharArraySet}) containing the words
* @see #makeStopSet(java.lang.String[], boolean) passing false to ignoreCase
*/
- public static final Set makeStopSet(List/*<String>*/ stopWords) {
+ public static final Set<Object> makeStopSet(List<?> stopWords) {
return makeStopSet(stopWords, false);
}
@@ -197,7 +113,7 @@ public final class StopFilter extends TokenFilter {
* @param ignoreCase If true, all words are lower cased first.
* @return a Set containing the words
*/
- public static final Set makeStopSet(String[] stopWords, boolean ignoreCase) {
+ public static final Set<Object> makeStopSet(String[] stopWords, boolean ignoreCase) {
CharArraySet stopSet = new CharArraySet(stopWords.length, ignoreCase);
stopSet.addAll(Arrays.asList(stopWords));
return stopSet;
@@ -205,11 +121,11 @@ public final class StopFilter extends TokenFilter {
/**
*
- * @param stopWords A List of Strings representing the stopwords
+ * @param stopWords A List of Strings or char[] or any other toString()-able list representing the stopwords
* @param ignoreCase if true, all words are lower cased first
- * @return A Set containing the words
+ * @return A Set ({@link CharArraySet}) containing the words
*/
- public static final Set makeStopSet(List/*<String>*/ stopWords, boolean ignoreCase){
+ public static final Set<Object> makeStopSet(List<?> stopWords, boolean ignoreCase){
CharArraySet stopSet = new CharArraySet(stopWords.size(), ignoreCase);
stopSet.addAll(stopWords);
return stopSet;
@@ -230,34 +146,10 @@ public final class StopFilter extends TokenFilter {
}
skippedPositions += posIncrAtt.getPositionIncrement();
}
- // reached EOS -- return null
+ // reached EOS -- return false
return false;
}
- /**
- * @see #setEnablePositionIncrementsDefault(boolean).
- * @deprecated Please specify this when you create the StopFilter
- */
- public static boolean getEnablePositionIncrementsDefault() {
- return ENABLE_POSITION_INCREMENTS_DEFAULT;
- }
-
- /**
- * Set the default position increments behavior of every StopFilter created from now on.
- * <p>
- * Note: behavior of a single StopFilter instance can be modified
- * with {@link #setEnablePositionIncrements(boolean)}.
- * This static method allows control over behavior of classes using StopFilters internally,
- * for example {@link org.apache.lucene.analysis.standard.StandardAnalyzer StandardAnalyzer}.
- * <p>
- * Default : false.
- * @see #setEnablePositionIncrements(boolean).
- * @deprecated Please specify this when you create the StopFilter
- */
- public static void setEnablePositionIncrementsDefault(boolean defaultValue) {
- ENABLE_POSITION_INCREMENTS_DEFAULT = defaultValue;
- }
-
/**
* @see #setEnablePositionIncrements(boolean).
*/
diff --git a/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java b/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java
index 3d8dce233fc..775dbaa9d0a 100644
--- a/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java
+++ b/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java
@@ -36,86 +36,25 @@ import java.util.Set;
* <ul>
* <li> As of 2.9, StopFilter preserves position
* increments by default
- * <li> As of 2.9, Tokens incorrectly identified as acronyms
+ * <li> As of 2.4, Tokens incorrectly identified as acronyms
* are corrected (see <a href="https://issues.apache.org/jira/browse/LUCENE-1068">LUCENE-1608</a>
* </ul>
*/
public class StandardAnalyzer extends Analyzer {
- private Set stopSet;
+ private Set<?> stopSet;
/**
* Specifies whether deprecated acronyms should be replaced with HOST type.
- * This is false by default to support backward compatibility.
- *
- * @deprecated this should be removed in the next release (3.0).
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
+ * See {@linkplain https://issues.apache.org/jira/browse/LUCENE-1068}
*/
- private boolean replaceInvalidAcronym = defaultReplaceInvalidAcronym;
+ private final boolean replaceInvalidAcronym,enableStopPositionIncrements;
- private static boolean defaultReplaceInvalidAcronym;
- private boolean enableStopPositionIncrements;
-
- // @deprecated
- private boolean useDefaultStopPositionIncrements;
-
- // Default to true (fixed the bug), unless the system prop is set
- static {
- final String v = System.getProperty("org.apache.lucene.analysis.standard.StandardAnalyzer.replaceInvalidAcronym");
- if (v == null || v.equals("true"))
- defaultReplaceInvalidAcronym = true;
- else
- defaultReplaceInvalidAcronym = false;
- }
-
- /**
- *
- * @return true if new instances of StandardTokenizer will
- * replace mischaracterized acronyms
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- * @deprecated This will be removed (hardwired to true) in 3.0
- */
- public static boolean getDefaultReplaceInvalidAcronym() {
- return defaultReplaceInvalidAcronym;
- }
-
- /**
- *
- * @param replaceInvalidAcronym Set to true to have new
- * instances of StandardTokenizer replace mischaracterized
- * acronyms by default. Set to false to preserve the
- * previous (before 2.4) buggy behavior. Alternatively,
- * set the system property
- * org.apache.lucene.analysis.standard.StandardAnalyzer.replaceInvalidAcronym
- * to false.
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- * @deprecated This will be removed (hardwired to true) in 3.0
- */
- public static void setDefaultReplaceInvalidAcronym(boolean replaceInvalidAcronym) {
- defaultReplaceInvalidAcronym = replaceInvalidAcronym;
- }
-
-
- /** An array containing some common English words that are usually not
- useful for searching.
- @deprecated Use {@link #STOP_WORDS_SET} instead */
- public static final String[] STOP_WORDS = StopAnalyzer.ENGLISH_STOP_WORDS;
-
/** An unmodifiable set containing some common English words that are usually not
useful for searching. */
- public static final Set/*<String>*/ STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
+ public static final Set<?> STOP_WORDS_SET = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
/** Builds an analyzer with the default stop words ({@link
* #STOP_WORDS_SET}).
- * @deprecated Use {@link #StandardAnalyzer(Version)} instead. */
- public StandardAnalyzer() {
- this(Version.LUCENE_24, STOP_WORDS_SET);
- }
-
- /** Builds an analyzer with the default stop words ({@link
- * #STOP_WORDS}).
* @param matchVersion Lucene version to match See {@link
* <a href="#version">above</a>}
*/
@@ -123,35 +62,15 @@ public class StandardAnalyzer extends Analyzer {
this(matchVersion, STOP_WORDS_SET);
}
- /** Builds an analyzer with the given stop words.
- * @deprecated Use {@link #StandardAnalyzer(Version, Set)}
- * instead */
- public StandardAnalyzer(Set stopWords) {
- this(Version.LUCENE_24, stopWords);
- }
-
/** Builds an analyzer with the given stop words.
* @param matchVersion Lucene version to match See {@link
* <a href="#version">above</a>}
* @param stopWords stop words */
- public StandardAnalyzer(Version matchVersion, Set stopWords) {
+ public StandardAnalyzer(Version matchVersion, Set<?> stopWords) {
stopSet = stopWords;
- init(matchVersion);
- }
-
- /** Builds an analyzer with the given stop words.
- * @deprecated Use {@link #StandardAnalyzer(Version, Set)} instead */
- public StandardAnalyzer(String[] stopWords) {
- this(Version.LUCENE_24, StopFilter.makeStopSet(stopWords));
- }
-
- /** Builds an analyzer with the stop words from the given file.
- * @see WordlistLoader#getWordSet(File)
- * @deprecated Use {@link #StandardAnalyzer(Version, File)}
- * instead
- */
- public StandardAnalyzer(File stopwords) throws IOException {
- this(Version.LUCENE_24, stopwords);
+ setOverridesTokenStreamMethod(StandardAnalyzer.class);
+ enableStopPositionIncrements = matchVersion.onOrAfter(Version.LUCENE_29);
+ replaceInvalidAcronym = matchVersion.onOrAfter(Version.LUCENE_24);
}
/** Builds an analyzer with the stop words from the given file.
@@ -160,17 +79,7 @@ public class StandardAnalyzer extends Analyzer {
* <a href="#version">above</a>}
* @param stopwords File to read stop words from */
public StandardAnalyzer(Version matchVersion, File stopwords) throws IOException {
- stopSet = WordlistLoader.getWordSet(stopwords);
- init(matchVersion);
- }
-
- /** Builds an analyzer with the stop words from the given reader.
- * @see WordlistLoader#getWordSet(Reader)
- * @deprecated Use {@link #StandardAnalyzer(Version, Reader)}
- * instead
- */
- public StandardAnalyzer(Reader stopwords) throws IOException {
- this(Version.LUCENE_24, stopwords);
+ this(matchVersion, WordlistLoader.getWordSet(stopwords));
}
/** Builds an analyzer with the stop words from the given reader.
@@ -179,84 +88,7 @@ public class StandardAnalyzer extends Analyzer {
* <a href="#version">above</a>}
* @param stopwords Reader to read stop words from */
public StandardAnalyzer(Version matchVersion, Reader stopwords) throws IOException {
- stopSet = WordlistLoader.getWordSet(stopwords);
- init(matchVersion);
- }
-
- /**
- *
- * @param replaceInvalidAcronym Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- *
- * @deprecated Remove in 3.X and make true the only valid value
- */
- public StandardAnalyzer(boolean replaceInvalidAcronym) {
- this(Version.LUCENE_24, STOP_WORDS_SET);
- this.replaceInvalidAcronym = replaceInvalidAcronym;
- useDefaultStopPositionIncrements = true;
- }
-
- /**
- * @param stopwords The stopwords to use
- * @param replaceInvalidAcronym Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- *
- * @deprecated Remove in 3.X and make true the only valid value
- */
- public StandardAnalyzer(Reader stopwords, boolean replaceInvalidAcronym) throws IOException{
- this(Version.LUCENE_24, stopwords);
- this.replaceInvalidAcronym = replaceInvalidAcronym;
- }
-
- /**
- * @param stopwords The stopwords to use
- * @param replaceInvalidAcronym Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- *
- * @deprecated Remove in 3.X and make true the only valid value
- */
- public StandardAnalyzer(File stopwords, boolean replaceInvalidAcronym) throws IOException{
- this(Version.LUCENE_24, stopwords);
- this.replaceInvalidAcronym = replaceInvalidAcronym;
- }
-
- /**
- *
- * @param stopwords The stopwords to use
- * @param replaceInvalidAcronym Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- *
- * @deprecated Remove in 3.X and make true the only valid value
- */
- public StandardAnalyzer(String [] stopwords, boolean replaceInvalidAcronym) throws IOException{
- this(Version.LUCENE_24, StopFilter.makeStopSet(stopwords));
- this.replaceInvalidAcronym = replaceInvalidAcronym;
- }
-
- /**
- * @param stopwords The stopwords to use
- * @param replaceInvalidAcronym Set to true if this analyzer should replace mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- *
- * @deprecated Remove in 3.X and make true the only valid value
- */
- public StandardAnalyzer(Set stopwords, boolean replaceInvalidAcronym) throws IOException{
- this(Version.LUCENE_24, stopwords);
- this.replaceInvalidAcronym = replaceInvalidAcronym;
- }
-
- private final void init(Version matchVersion) {
- setOverridesTokenStreamMethod(StandardAnalyzer.class);
- if (matchVersion.onOrAfter(Version.LUCENE_29)) {
- enableStopPositionIncrements = true;
- } else {
- useDefaultStopPositionIncrements = true;
- }
+ this(matchVersion, WordlistLoader.getWordSet(stopwords));
}
/** Constructs a {@link StandardTokenizer} filtered by a {@link
@@ -266,11 +98,7 @@ public class StandardAnalyzer extends Analyzer {
tokenStream.setMaxTokenLength(maxTokenLength);
TokenStream result = new StandardFilter(tokenStream);
result = new LowerCaseFilter(result);
- if (useDefaultStopPositionIncrements) {
- result = new StopFilter(result, stopSet);
- } else {
- result = new StopFilter(enableStopPositionIncrements, result, stopSet);
- }
+ result = new StopFilter(enableStopPositionIncrements, result, stopSet);
return result;
}
@@ -301,7 +129,6 @@ public class StandardAnalyzer extends Analyzer {
return maxTokenLength;
}
- /** @deprecated Use {@link #tokenStream} instead */
public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException {
if (overridesTokenStreamMethod) {
// LUCENE-1678: force fallback to tokenStream() if we
@@ -316,11 +143,7 @@ public class StandardAnalyzer extends Analyzer {
streams.tokenStream = new StandardTokenizer(reader);
streams.filteredTokenStream = new StandardFilter(streams.tokenStream);
streams.filteredTokenStream = new LowerCaseFilter(streams.filteredTokenStream);
- if (useDefaultStopPositionIncrements) {
- streams.filteredTokenStream = new StopFilter(streams.filteredTokenStream, stopSet);
- } else {
- streams.filteredTokenStream = new StopFilter(enableStopPositionIncrements, streams.filteredTokenStream, stopSet);
- }
+ streams.filteredTokenStream = new StopFilter(enableStopPositionIncrements, streams.filteredTokenStream, stopSet);
} else {
streams.tokenStream.reset(reader);
}
@@ -330,26 +153,4 @@ public class StandardAnalyzer extends Analyzer {
return streams.filteredTokenStream;
}
-
- /**
- *
- * @return true if this Analyzer is replacing mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- * @deprecated This will be removed (hardwired to true) in 3.0
- */
- public boolean isReplaceInvalidAcronym() {
- return replaceInvalidAcronym;
- }
-
- /**
- *
- * @param replaceInvalidAcronym Set to true if this Analyzer is replacing mischaracterized acronyms in the StandardTokenizer
- *
- * See https://issues.apache.org/jira/browse/LUCENE-1068
- * @deprecated This will be removed (hardwired to true) in 3.0
- */
- public void setReplaceInvalidAcronym(boolean replaceInvalidAcronym) {
- this.replaceInvalidAcronym = replaceInvalidAcronym;
- }
}
diff --git a/src/java/org/apache/lucene/util/Version.java b/src/java/org/apache/lucene/util/Version.java
index 853d457c5e5..b01ad36acc5 100644
--- a/src/java/org/apache/lucene/util/Version.java
+++ b/src/java/org/apache/lucene/util/Version.java
@@ -37,6 +37,18 @@ public final class Version extends Parameter implements Serializable {
*/
public static final Version LUCENE_CURRENT = new Version("LUCENE_CURRENT", 0);
+ /** Match settings and bugs in Lucene's 2.0 release. */
+ public static final Version LUCENE_20 = new Version("LUCENE_20", 2000);
+
+ /** Match settings and bugs in Lucene's 2.1 release. */
+ public static final Version LUCENE_21 = new Version("LUCENE_21", 2100);
+
+ /** Match settings and bugs in Lucene's 2.2 release. */
+ public static final Version LUCENE_22 = new Version("LUCENE_22", 2200);
+
+ /** Match settings and bugs in Lucene's 2.3 release. */
+ public static final Version LUCENE_23 = new Version("LUCENE_23", 2300);
+
/** Match settings and bugs in Lucene's 2.4 release. */
public static final Version LUCENE_24 = new Version("LUCENE_24", 2400);
diff --git a/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java b/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
index f18f31e7afd..65c71aef78b 100644
--- a/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
+++ b/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java
@@ -68,7 +68,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase
Directory dir = new MockRAMDirectory();
SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), dp, IndexWriter.MaxFieldLength.UNLIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), dp, IndexWriter.MaxFieldLength.UNLIMITED);
// Force frequent flushes
writer.setMaxBufferedDocs(2);
Document doc = new Document();
@@ -84,7 +84,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase
writer.close();
copyFiles(dir, cp);
- writer = new IndexWriter(dir, new StandardAnalyzer(), dp, IndexWriter.MaxFieldLength.UNLIMITED);
+ writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), dp, IndexWriter.MaxFieldLength.UNLIMITED);
copyFiles(dir, cp);
for(int i=0;i<7;i++) {
writer.addDocument(doc);
@@ -96,7 +96,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase
writer.close();
copyFiles(dir, cp);
dp.release();
- writer = new IndexWriter(dir, new StandardAnalyzer(), dp, IndexWriter.MaxFieldLength.UNLIMITED);
+ writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), dp, IndexWriter.MaxFieldLength.UNLIMITED);
writer.close();
try {
copyFiles(dir, cp);
@@ -112,7 +112,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase
final long stopTime = System.currentTimeMillis() + 7000;
SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
- final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), dp, IndexWriter.MaxFieldLength.UNLIMITED);
+ final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), dp, IndexWriter.MaxFieldLength.UNLIMITED);
// Force frequent flushes
writer.setMaxBufferedDocs(2);
diff --git a/src/test/org/apache/lucene/analysis/TestAnalyzers.java b/src/test/org/apache/lucene/analysis/TestAnalyzers.java
index d005809f486..b5039d9b3c8 100644
--- a/src/test/org/apache/lucene/analysis/TestAnalyzers.java
+++ b/src/test/org/apache/lucene/analysis/TestAnalyzers.java
@@ -74,7 +74,7 @@ public class TestAnalyzers extends BaseTokenStreamTestCase {
}
public void testStop() throws Exception {
- Analyzer a = new StopAnalyzer();
+ Analyzer a = new StopAnalyzer(true);
assertAnalyzesTo(a, "foo bar FOO BAR",
new String[] { "foo", "bar", "foo", "bar" });
assertAnalyzesTo(a, "foo a bar such FOO THESE BAR",
@@ -120,6 +120,10 @@ public class TestAnalyzers extends BaseTokenStreamTestCase {
}
private static class MyStandardAnalyzer extends StandardAnalyzer {
+ public MyStandardAnalyzer() {
+ super(org.apache.lucene.util.Version.LUCENE_CURRENT);
+ }
+
public TokenStream tokenStream(String field, Reader reader) {
return new WhitespaceAnalyzer().tokenStream(field, reader);
}
diff --git a/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java b/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java
index 3ae40923b71..762995b9058 100644
--- a/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java
+++ b/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java
@@ -26,16 +26,16 @@ import java.io.StringReader;
public class TestStandardAnalyzer extends BaseTokenStreamTestCase {
- private Analyzer a = new StandardAnalyzer();
+ private Analyzer a = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
public void testMaxTermLength() throws Exception {
- StandardAnalyzer sa = new StandardAnalyzer();
+ StandardAnalyzer sa = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
sa.setMaxTokenLength(5);
assertAnalyzesTo(sa, "ab cd toolong xy z", new String[]{"ab", "cd", "xy", "z"});
}
public void testMaxTermLength2() throws Exception {
- StandardAnalyzer sa = new StandardAnalyzer();
+ StandardAnalyzer sa = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
assertAnalyzesTo(sa, "ab cd toolong xy z", new String[]{"ab", "cd", "toolong", "xy", "z"});
sa.setMaxTokenLength(5);
@@ -99,23 +99,23 @@ public class TestStandardAnalyzer extends BaseTokenStreamTestCase {
public void testLucene1140() throws Exception {
try {
- StandardAnalyzer analyzer = new StandardAnalyzer(true);
+ StandardAnalyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
assertAnalyzesTo(analyzer, "www.nutch.org.", new String[]{ "www.nutch.org" }, new String[] { "<HOST>" });
} catch (NullPointerException e) {
- assertTrue("Should not throw an NPE and it did", false);
+ fail("Should not throw an NPE and it did");
}
}
public void testDomainNames() throws Exception {
// Don't reuse a because we alter its state (setReplaceInvalidAcronym)
- StandardAnalyzer a2 = new StandardAnalyzer();
+ StandardAnalyzer a2 = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
// domain names
assertAnalyzesTo(a2, "www.nutch.org", new String[]{"www.nutch.org"});
//Notice the trailing . See https://issues.apache.org/jira/browse/LUCENE-1068.
// the following should be recognized as HOST:
assertAnalyzesTo(a2, "www.nutch.org.", new String[]{ "www.nutch.org" }, new String[] { "<HOST>" });
- a2.setReplaceInvalidAcronym(false);
+ a2 = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_23);
assertAnalyzesTo(a2, "www.nutch.org.", new String[]{ "wwwnutchorg" }, new String[] { "<ACRONYM>" });
}
@@ -220,11 +220,4 @@ public class TestStandardAnalyzer extends BaseTokenStreamTestCase {
"<ALPHANUM>", "<NUM>", "<HOST>", "<NUM>", "<ALPHANUM>",
"<ALPHANUM>", "<HOST>"});
}
-
- /** @deprecated this should be removed in the 3.0. */
- public void testDeprecatedAcronyms() throws Exception {
- // test backward compatibility for applications that require the old behavior.
- // this should be removed once replaceDepAcronym is removed.
- assertAnalyzesTo(a, "lucene.apache.org.", new String[]{ "lucene.apache.org" }, new String[] { "<HOST>" });
- }
}
diff --git a/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java b/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java
index f52e1287b1c..68b9194c22e 100644
--- a/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java
+++ b/src/test/org/apache/lucene/analysis/TestStopAnalyzer.java
@@ -61,7 +61,7 @@ public class TestStopAnalyzer extends BaseTokenStreamTestCase {
stopWordsSet.add("good");
stopWordsSet.add("test");
stopWordsSet.add("analyzer");
- StopAnalyzer newStop = new StopAnalyzer((String[])stopWordsSet.toArray(new String[3]));
+ StopAnalyzer newStop = new StopAnalyzer(stopWordsSet, false);
StringReader reader = new StringReader("This is a good test of the english stop analyzer");
TokenStream stream = newStop.tokenStream("test", reader);
assertNotNull(stream);
@@ -76,29 +76,23 @@ public class TestStopAnalyzer extends BaseTokenStreamTestCase {
}
public void testStopListPositions() throws IOException {
- boolean defaultEnable = StopFilter.getEnablePositionIncrementsDefault();
- StopFilter.setEnablePositionIncrementsDefault(true);
- try {
- Set stopWordsSet = new HashSet();
- stopWordsSet.add("good");
- stopWordsSet.add("test");
- stopWordsSet.add("analyzer");
- StopAnalyzer newStop = new StopAnalyzer((String[])stopWordsSet.toArray(new String[3]));
- StringReader reader = new StringReader("This is a good test of the english stop analyzer with positions");
- int expectedIncr[] = { 1, 1, 1, 3, 1, 1, 1, 2, 1};
- TokenStream stream = newStop.tokenStream("test", reader);
- assertNotNull(stream);
- int i = 0;
- TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
- PositionIncrementAttribute posIncrAtt = stream.addAttribute(PositionIncrementAttribute.class);
+ Set stopWordsSet = new HashSet();
+ stopWordsSet.add("good");
+ stopWordsSet.add("test");
+ stopWordsSet.add("analyzer");
+ StopAnalyzer newStop = new StopAnalyzer(stopWordsSet, true);
+ StringReader reader = new StringReader("This is a good test of the english stop analyzer with positions");
+ int expectedIncr[] = { 1, 1, 1, 3, 1, 1, 1, 2, 1};
+ TokenStream stream = newStop.tokenStream("test", reader);
+ assertNotNull(stream);
+ int i = 0;
+ TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
+ PositionIncrementAttribute posIncrAtt = stream.addAttribute(PositionIncrementAttribute.class);
- while (stream.incrementToken()) {
- String text = termAtt.term();
- assertFalse(stopWordsSet.contains(text));
- assertEquals(expectedIncr[i++],posIncrAtt.getPositionIncrement());
- }
- } finally {
- StopFilter.setEnablePositionIncrementsDefault(defaultEnable);
+ while (stream.incrementToken()) {
+ String text = termAtt.term();
+ assertFalse(stopWordsSet.contains(text));
+ assertEquals(expectedIncr[i++],posIncrAtt.getPositionIncrement());
}
}
diff --git a/src/test/org/apache/lucene/analysis/TestStopFilter.java b/src/test/org/apache/lucene/analysis/TestStopFilter.java
index 637c5564338..263a9b35a19 100644
--- a/src/test/org/apache/lucene/analysis/TestStopFilter.java
+++ b/src/test/org/apache/lucene/analysis/TestStopFilter.java
@@ -23,7 +23,9 @@ import org.apache.lucene.util.English;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Set;
+import java.util.HashSet;
public class TestStopFilter extends BaseTokenStreamTestCase {
@@ -34,8 +36,8 @@ public class TestStopFilter extends BaseTokenStreamTestCase {
public void testExactCase() throws IOException {
StringReader reader = new StringReader("Now is The Time");
- String[] stopWords = new String[] { "is", "the", "Time" };
- TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords);
+ Set<String> stopWords = new HashSet(Arrays.asList("is", "the", "Time"));
+ TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords, false);
final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
assertTrue(stream.incrementToken());
assertEquals("Now", termAtt.term());
@@ -46,7 +48,7 @@ public class TestStopFilter extends BaseTokenStreamTestCase {
public void testIgnoreCase() throws IOException {
StringReader reader = new StringReader("Now is The Time");
- String[] stopWords = new String[] { "is", "the", "Time" };
+ Set<String> stopWords = new HashSet(Arrays.asList( "is", "the", "Time" ));
TokenStream stream = new StopFilter(false, new WhitespaceTokenizer(reader), stopWords, true);
final TermAttribute termAtt = stream.getAttribute(TermAttribute.class);
assertTrue(stream.incrementToken());
diff --git a/src/test/org/apache/lucene/document/TestBinaryDocument.java b/src/test/org/apache/lucene/document/TestBinaryDocument.java
index bb8adc7a616..25e1607ed8d 100644
--- a/src/test/org/apache/lucene/document/TestBinaryDocument.java
+++ b/src/test/org/apache/lucene/document/TestBinaryDocument.java
@@ -59,7 +59,7 @@ public class TestBinaryDocument extends LuceneTestCase
/** add the doc to a ram index */
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(doc);
writer.close();
@@ -97,7 +97,7 @@ public class TestBinaryDocument extends LuceneTestCase
/** add the doc to a ram index */
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(doc);
writer.close();
diff --git a/src/test/org/apache/lucene/document/TestDocument.java b/src/test/org/apache/lucene/document/TestDocument.java
index 3105e2c940a..079ab6e77e6 100644
--- a/src/test/org/apache/lucene/document/TestDocument.java
+++ b/src/test/org/apache/lucene/document/TestDocument.java
@@ -154,7 +154,7 @@ public class TestDocument extends LuceneTestCase
public void testGetValuesForIndexedDocument() throws Exception
{
RAMDirectory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(makeDocumentWithFields());
writer.close();
@@ -225,7 +225,7 @@ public class TestDocument extends LuceneTestCase
doc.add(new Field("keyword", "test", Field.Store.YES, Field.Index.NOT_ANALYZED));
RAMDirectory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(doc);
field.setValue("id2");
writer.addDocument(doc);
diff --git a/src/test/org/apache/lucene/index/TestDirectoryReader.java b/src/test/org/apache/lucene/index/TestDirectoryReader.java
index d7be9e99f96..d1d117b32ad 100644
--- a/src/test/org/apache/lucene/index/TestDirectoryReader.java
+++ b/src/test/org/apache/lucene/index/TestDirectoryReader.java
@@ -193,7 +193,7 @@ public class TestDirectoryReader extends LuceneTestCase {
}
private void addDoc(RAMDirectory ramDir1, String s, boolean create) throws IOException {
- IndexWriter iw = new IndexWriter(ramDir1, new StandardAnalyzer(), create, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter iw = new IndexWriter(ramDir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), create, IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
doc.add(new Field("body", s, Field.Store.YES, Field.Index.ANALYZED));
iw.addDocument(doc);
diff --git a/src/test/org/apache/lucene/index/TestDocumentWriter.java b/src/test/org/apache/lucene/index/TestDocumentWriter.java
index 43fd5bcfb33..19300a41b86 100644
--- a/src/test/org/apache/lucene/index/TestDocumentWriter.java
+++ b/src/test/org/apache/lucene/index/TestDocumentWriter.java
@@ -259,7 +259,7 @@ public class TestDocumentWriter extends BaseTokenStreamTestCase {
doc.add(new Field("f2", "v1", Store.YES, Index.NOT_ANALYZED, TermVector.WITH_POSITIONS_OFFSETS));
doc.add(new Field("f2", "v2", Store.YES, Index.NOT_ANALYZED, TermVector.NO));
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(doc);
writer.close();
@@ -292,7 +292,7 @@ public class TestDocumentWriter extends BaseTokenStreamTestCase {
doc.add(f);
doc.add(new Field("f2", "v2", Store.YES, Index.NO));
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(doc);
writer.optimize(); // be sure to have a single segment
writer.close();
diff --git a/src/test/org/apache/lucene/index/TestIndexReader.java b/src/test/org/apache/lucene/index/TestIndexReader.java
index 1d685a42f5e..88b40c2bbc4 100644
--- a/src/test/org/apache/lucene/index/TestIndexReader.java
+++ b/src/test/org/apache/lucene/index/TestIndexReader.java
@@ -76,7 +76,7 @@ public class TestIndexReader extends LuceneTestCase
commitUserData.put("foo", "fighters");
// set up writer
- IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
for(int i=0;i<27;i++)
addDocumentWithFields(writer);
@@ -98,7 +98,7 @@ public class TestIndexReader extends LuceneTestCase
assertTrue(c.equals(r.getIndexCommit()));
// Change the index
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
for(int i=0;i<7;i++)
addDocumentWithFields(writer);
@@ -109,7 +109,7 @@ public class TestIndexReader extends LuceneTestCase
assertFalse(r2.getIndexCommit().isOptimized());
r3.close();
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writer.optimize();
writer.close();
@@ -123,19 +123,19 @@ public class TestIndexReader extends LuceneTestCase
public void testIsCurrent() throws Exception
{
RAMDirectory d = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDocumentWithFields(writer);
writer.close();
// set up reader:
IndexReader reader = IndexReader.open(d, false);
assertTrue(reader.isCurrent());
// modify index by adding another document:
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
addDocumentWithFields(writer);
writer.close();
assertFalse(reader.isCurrent());
// re-create index:
- writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDocumentWithFields(writer);
writer.close();
assertFalse(reader.isCurrent());
@@ -151,7 +151,7 @@ public class TestIndexReader extends LuceneTestCase
{
RAMDirectory d = new MockRAMDirectory();
// set up writer
- IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDocumentWithFields(writer);
writer.close();
// set up reader
@@ -163,7 +163,7 @@ public class TestIndexReader extends LuceneTestCase
assertTrue(fieldNames.contains("unstored"));
reader.close();
// add more documents
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
// want to get some more segments here
for (int i = 0; i < 5*writer.getMergeFactor(); i++)
{
@@ -243,7 +243,7 @@ public class TestIndexReader extends LuceneTestCase
public void testTermVectors() throws Exception {
RAMDirectory d = new MockRAMDirectory();
// set up writer
- IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
// want to get some more segments here
// new termvector fields
for (int i = 0; i < 5 * writer.getMergeFactor(); i++) {
@@ -1418,7 +1418,7 @@ public class TestIndexReader extends LuceneTestCase
RAMDirectory d = new MockRAMDirectory();
// set up writer
- IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
for(int i=0;i<27;i++)
addDocumentWithFields(writer);
@@ -1434,7 +1434,7 @@ public class TestIndexReader extends LuceneTestCase
assertTrue(c.equals(r.getIndexCommit()));
// Change the index
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
for(int i=0;i<7;i++)
addDocumentWithFields(writer);
@@ -1445,7 +1445,7 @@ public class TestIndexReader extends LuceneTestCase
assertFalse(r2.getIndexCommit().isOptimized());
r2.close();
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writer.optimize();
writer.close();
@@ -1459,7 +1459,7 @@ public class TestIndexReader extends LuceneTestCase
public void testReadOnly() throws Throwable {
RAMDirectory d = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDocumentWithFields(writer);
writer.commit();
addDocumentWithFields(writer);
@@ -1473,7 +1473,7 @@ public class TestIndexReader extends LuceneTestCase
// expected
}
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
addDocumentWithFields(writer);
writer.close();
@@ -1490,7 +1490,7 @@ public class TestIndexReader extends LuceneTestCase
// expected
}
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writer.optimize();
writer.close();
@@ -1508,7 +1508,7 @@ public class TestIndexReader extends LuceneTestCase
}
// Make sure write lock isn't held
- writer = new IndexWriter(d, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writer.close();
r3.close();
@@ -1518,7 +1518,7 @@ public class TestIndexReader extends LuceneTestCase
// LUCENE-1474
public void testIndexReader() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.UNLIMITED);
writer.addDocument(createDocument("a"));
writer.addDocument(createDocument("b"));
@@ -1536,7 +1536,7 @@ public class TestIndexReader extends LuceneTestCase
public void testIndexReaderUnDeleteAll() throws Exception {
MockRAMDirectory dir = new MockRAMDirectory();
dir.setPreventDoubleWrite(false);
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.UNLIMITED);
writer.addDocument(createDocument("a"));
writer.addDocument(createDocument("b"));
@@ -1578,7 +1578,7 @@ public class TestIndexReader extends LuceneTestCase
Directory dir = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(),
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
diff --git a/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java b/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
index c590f922677..eed2e9efcae 100644
--- a/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
+++ b/src/test/org/apache/lucene/index/TestIndexReaderCloneNorms.java
@@ -69,7 +69,7 @@ public class TestIndexReaderCloneNorms extends LuceneTestCase {
protected void setUp() throws Exception {
super.setUp();
similarityOne = new SimilarityOne();
- anlzr = new StandardAnalyzer();
+ anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
}
/**
diff --git a/src/test/org/apache/lucene/index/TestIndexReaderReopen.java b/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
index d332fa28748..111e42176f8 100644
--- a/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
+++ b/src/test/org/apache/lucene/index/TestIndexReaderReopen.java
@@ -687,7 +687,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
final Directory dir = new MockRAMDirectory();
final int n = 150;
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
for (int i = 0; i < n; i++) {
writer.addDocument(createDocument(i, 3));
}
@@ -705,7 +705,7 @@ public class TestIndexReaderReopen extends LuceneTestCase {
modifier.deleteDocument(i % modifier.maxDoc());
modifier.close();
} else {
- IndexWriter modifier = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter modifier = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.addDocument(createDocument(n + i, 6));
modifier.close();
}
diff --git a/src/test/org/apache/lucene/index/TestIndexWriter.java b/src/test/org/apache/lucene/index/TestIndexWriter.java
index 282937be8a4..74bcc86cda5 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -543,7 +543,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
*/
public void testWickedLongTerm() throws IOException {
RAMDirectory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
char[] chars = new char[DocumentsWriter.CHAR_BLOCK_SIZE-1];
Arrays.fill(chars, 'x');
@@ -587,7 +587,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// maximum length term, and search on that term:
doc = new Document();
doc.add(new Field("content", bigTerm, Field.Store.NO, Field.Index.ANALYZED));
- StandardAnalyzer sa = new StandardAnalyzer();
+ StandardAnalyzer sa = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
sa.setMaxTokenLength(100000);
writer = new IndexWriter(dir, sa, IndexWriter.MaxFieldLength.LIMITED);
writer.addDocument(doc);
@@ -1573,7 +1573,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
*/
public void testBadSegment() throws IOException {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter ir = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter ir = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document document = new Document();
document.add(new Field("tvtest", "", Field.Store.NO, Field.Index.ANALYZED,
@@ -1586,7 +1586,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1008
public void testNoTermVectorAfterTermVector() throws IOException {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document document = new Document();
document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
Field.TermVector.YES));
@@ -1612,7 +1612,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1010
public void testNoTermVectorAfterTermVectorMerge() throws IOException {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document document = new Document();
document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
Field.TermVector.YES));
@@ -1644,7 +1644,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
int pri = Thread.currentThread().getPriority();
try {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document document = new Document();
document.add(new Field("tvtest", "a b c", Field.Store.NO, Field.Index.ANALYZED,
Field.TermVector.YES));
@@ -1682,7 +1682,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1013
public void testSetMaxMergeDocs() throws IOException {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter iw = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
iw.setMergeScheduler(new MyMergeScheduler());
iw.setMaxMergeDocs(20);
iw.setMaxBufferedDocs(2);
@@ -2730,7 +2730,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
Directory dir = new MockRAMDirectory();
for(int iter=0;iter<2;iter++) {
IndexWriter writer = new IndexWriter(dir,
- new StandardAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
writer.setMaxBufferedDocs(2);
writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
writer.setMergeScheduler(new SerialMergeScheduler());
@@ -2763,7 +2763,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
reader.close();
writer = new IndexWriter(dir,
- new StandardAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
writer.setMaxBufferedDocs(2);
writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
writer.setMergeScheduler(new SerialMergeScheduler());
@@ -2782,7 +2782,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
Directory dir = new MockRAMDirectory();
for(int iter=0;iter<2;iter++) {
IndexWriter writer = new IndexWriter(dir,
- new StandardAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED);
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED);
writer.setMaxBufferedDocs(2);
writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
writer.setMergeScheduler(new SerialMergeScheduler());
@@ -2819,7 +2819,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
public void testTermVectorCorruption3() throws IOException {
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
@@ -2841,7 +2841,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
writer.close();
writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
@@ -2889,7 +2889,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
public void testExpungeDeletes() throws IOException {
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
writer.setRAMBufferSizeMB(IndexWriter.DISABLE_AUTO_FLUSH);
@@ -2917,7 +2917,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
ir.close();
writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
assertEquals(8, writer.numDocs());
assertEquals(10, writer.maxDoc());
@@ -2935,7 +2935,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
public void testExpungeDeletes2() throws IOException {
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
writer.setMergeFactor(50);
@@ -2964,7 +2964,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
ir.close();
writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMergeFactor(3);
assertEquals(49, writer.numDocs());
@@ -2982,7 +2982,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
public void testExpungeDeletes3() throws IOException {
Directory dir = new MockRAMDirectory();
IndexWriter writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(2);
writer.setMergeFactor(50);
@@ -3011,7 +3011,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
ir.close();
writer = new IndexWriter(dir,
- new StandardAnalyzer(),
+ new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
IndexWriter.MaxFieldLength.LIMITED);
// Force many merges to happen
writer.setMergeFactor(3);
@@ -4014,7 +4014,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
final List thrown = new ArrayList();
- final IndexWriter writer = new IndexWriter(new MockRAMDirectory(), new StandardAnalyzer(), IndexWriter.MaxFieldLength.UNLIMITED) {
+ final IndexWriter writer = new IndexWriter(new MockRAMDirectory(), new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.UNLIMITED) {
public void message(final String message) {
if (message.startsWith("now flush at close") && 0 == thrown.size()) {
thrown.add(null);
@@ -4167,7 +4167,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1448
public void testEndOffsetPositionStopFilter() throws Exception {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StopAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StopAnalyzer(true), IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
Field f = new Field("field", "abcd the", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
doc.add(f);
@@ -4189,7 +4189,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandard() throws Exception {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
Field f = new Field("field", "abcd the ", Field.Store.NO,
Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4219,7 +4219,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandardEmptyField() throws Exception {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
Field f = new Field("field", "", Field.Store.NO,
Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS);
@@ -4246,7 +4246,7 @@ public class TestIndexWriter extends BaseTokenStreamTestCase {
// LUCENE-1448
public void testEndOffsetPositionStandardEmptyField2() throws Exception {
MockRAMDirectory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
Field f = new Field("field", "abcd", Field.Store.NO,
diff --git a/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java b/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
index 34379044c3f..4a12aa5305a 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
@@ -75,10 +75,10 @@ public class TestIndexWriterLockRelease extends LuceneTestCase {
IndexWriter im;
FSDirectory dir = FSDirectory.open(this.__test_dir);
try {
- im = new IndexWriter(dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ im = new IndexWriter(dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
} catch (FileNotFoundException e) {
try {
- im = new IndexWriter(dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ im = new IndexWriter(dir, new org.apache.lucene.analysis.standard.StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
} catch (FileNotFoundException e1) {
}
} finally {
diff --git a/src/test/org/apache/lucene/index/TestIndexWriterMerging.java b/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
index 4c1c665546e..0e3588b03ca 100644
--- a/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
+++ b/src/test/org/apache/lucene/index/TestIndexWriterMerging.java
@@ -56,7 +56,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
Directory merged = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(merged, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(merged, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMergeFactor(2);
writer.addIndexesNoOptimize(new Directory[]{indexA, indexB});
@@ -93,7 +93,7 @@ public class TestIndexWriterMerging extends LuceneTestCase
private void fillIndex(Directory dir, int start, int numDocs) throws IOException
{
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMergeFactor(2);
writer.setMaxBufferedDocs(2);
diff --git a/src/test/org/apache/lucene/index/TestNorms.java b/src/test/org/apache/lucene/index/TestNorms.java
index 466858d6183..9b9a3a5e50a 100755
--- a/src/test/org/apache/lucene/index/TestNorms.java
+++ b/src/test/org/apache/lucene/index/TestNorms.java
@@ -63,7 +63,7 @@ public class TestNorms extends LuceneTestCase {
protected void setUp() throws Exception {
super.setUp();
similarityOne = new SimilarityOne();
- anlzr = new StandardAnalyzer();
+ anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
}
/**
diff --git a/src/test/org/apache/lucene/index/TestOmitTf.java b/src/test/org/apache/lucene/index/TestOmitTf.java
index 70df4dac06c..56d2207c50d 100644
--- a/src/test/org/apache/lucene/index/TestOmitTf.java
+++ b/src/test/org/apache/lucene/index/TestOmitTf.java
@@ -57,7 +57,7 @@ public class TestOmitTf extends LuceneTestCase {
// omitTermFreqAndPositions bit in the FieldInfo
public void testOmitTermFreqAndPositions() throws Exception {
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
Document d = new Document();
@@ -103,7 +103,7 @@ public class TestOmitTf extends LuceneTestCase {
// omitTermFreqAndPositions for the same field works
public void testMixedMerge() throws Exception {
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(3);
writer.setMergeFactor(2);
@@ -156,7 +156,7 @@ public class TestOmitTf extends LuceneTestCase {
// field,
public void testMixedRAM() throws Exception {
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(10);
writer.setMergeFactor(2);
@@ -204,7 +204,7 @@ public class TestOmitTf extends LuceneTestCase {
// Verifies no *.prx exists when all fields omit term freq:
public void testNoPrxFile() throws Throwable {
Directory ram = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(ram, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(3);
writer.setMergeFactor(2);
@@ -235,7 +235,7 @@ public class TestOmitTf extends LuceneTestCase {
// Test scores with one field with Term Freqs and one without, otherwise with equal content
public void testBasic() throws Exception {
Directory dir = new MockRAMDirectory();
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter writer = new IndexWriter(dir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
writer.setMergeFactor(2);
writer.setMaxBufferedDocs(2);
diff --git a/src/test/org/apache/lucene/index/TestParallelReader.java b/src/test/org/apache/lucene/index/TestParallelReader.java
index 78659e2767c..85113b4eed3 100644
--- a/src/test/org/apache/lucene/index/TestParallelReader.java
+++ b/src/test/org/apache/lucene/index/TestParallelReader.java
@@ -105,7 +105,7 @@ public class TestParallelReader extends LuceneTestCase {
// one document only:
Directory dir2 = new MockRAMDirectory();
- IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
w2.addDocument(d3);
@@ -150,13 +150,13 @@ public class TestParallelReader extends LuceneTestCase {
Directory dir2 = getDir2();
// add another document to ensure that the indexes are not optimized
- IndexWriter modifier = new IndexWriter(dir1, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter modifier = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
Document d = new Document();
d.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
modifier.addDocument(d);
modifier.close();
- modifier = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
d = new Document();
d.add(new Field("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
modifier.addDocument(d);
@@ -169,7 +169,7 @@ public class TestParallelReader extends LuceneTestCase {
assertFalse(pr.isOptimized());
pr.close();
- modifier = new IndexWriter(dir1, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.optimize();
modifier.close();
@@ -181,7 +181,7 @@ public class TestParallelReader extends LuceneTestCase {
pr.close();
- modifier = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.optimize();
modifier.close();
@@ -232,7 +232,7 @@ public class TestParallelReader extends LuceneTestCase {
// Fields 1-4 indexed together:
private Searcher single() throws IOException {
Directory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d1 = new Document();
d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -262,7 +262,7 @@ public class TestParallelReader extends LuceneTestCase {
private Directory getDir1() throws IOException {
Directory dir1 = new MockRAMDirectory();
- IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d1 = new Document();
d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -277,7 +277,7 @@ public class TestParallelReader extends LuceneTestCase {
private Directory getDir2() throws IOException {
Directory dir2 = new RAMDirectory();
- IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
d3.add(new Field("f4", "v1", Field.Store.YES, Field.Index.ANALYZED));
diff --git a/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java b/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
index 9331b9298cc..852ed01d38d 100644
--- a/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
+++ b/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
@@ -70,7 +70,7 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
public void testSimple() throws Exception {
String[] fields = {"b", "t"};
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query q = mfqp.parse("one");
assertEquals("b:one t:one", q.toString());
@@ -133,7 +133,7 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
boosts.put("b", Float.valueOf(5));
boosts.put("t", Float.valueOf(10));
String[] fields = {"b", "t"};
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(), boosts);
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), boosts);
//Check for simple
@@ -159,24 +159,24 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
public void testStaticMethod1() throws ParseException {
String[] fields = {"b", "t"};
String[] queries = {"one", "two"};
- Query q = MultiFieldQueryParser.parse(queries, fields, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(queries, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one t:two", q.toString());
String[] queries2 = {"+one", "+two"};
- q = MultiFieldQueryParser.parse(queries2, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(queries2, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(+b:one) (+t:two)", q.toString());
String[] queries3 = {"one", "+two"};
- q = MultiFieldQueryParser.parse(queries3, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(queries3, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one (+t:two)", q.toString());
String[] queries4 = {"one +more", "+two"};
- q = MultiFieldQueryParser.parse(queries4, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(queries4, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(b:one +b:more) (+t:two)", q.toString());
String[] queries5 = {"blah"};
try {
- q = MultiFieldQueryParser.parse(queries5, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(queries5, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -198,15 +198,15 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
public void testStaticMethod2() throws ParseException {
String[] fields = {"b", "t"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:one", q.toString());
- q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -217,17 +217,17 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
String[] fields = {"b", "t"};
//int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
- Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer());//, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));//, fields, flags, new StandardAnalyzer());
assertEquals("+b:one -t:one", q.toString());
- q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -239,12 +239,12 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
String[] fields = {"f1", "f2", "f3"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT, BooleanClause.Occur.SHOULD};
- Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+f1:one -f2:two f3:three", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -255,12 +255,12 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
String[] queries = {"one", "two"};
String[] fields = {"b", "t"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:two", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -282,7 +282,7 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
}
public void testStopWordSearching() throws Exception {
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
Directory ramDir = new RAMDirectory();
IndexWriter iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -304,7 +304,7 @@ public class TestMultiFieldQueryParser extends BaseTokenStreamTestCase {
* Return empty tokens for field "f1".
*/
private static class AnalyzerReturningNull extends Analyzer {
- StandardAnalyzer stdAnalyzer = new StandardAnalyzer();
+ StandardAnalyzer stdAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
public AnalyzerReturningNull() {
}
diff --git a/src/test/org/apache/lucene/queryParser/TestQueryParser.java b/src/test/org/apache/lucene/queryParser/TestQueryParser.java
index 51902a48618..a713efae0a0 100644
--- a/src/test/org/apache/lucene/queryParser/TestQueryParser.java
+++ b/src/test/org/apache/lucene/queryParser/TestQueryParser.java
@@ -68,11 +68,11 @@ import org.apache.lucene.util.LocalizedTestCase;
public class TestQueryParser extends LocalizedTestCase {
public TestQueryParser(String name) {
- super(name, new HashSet(Arrays.asList(new String[]{
+ super(name, new HashSet(Arrays.asList(
"testLegacyDateRange", "testDateRange",
"testCJK", "testNumber", "testFarsiRangeCollating",
"testLocalDateFormat"
- })));
+ )));
}
public static Analyzer qpAnalyzer = new QPTestAnalyzer();
@@ -291,7 +291,7 @@ public class TestQueryParser extends LocalizedTestCase {
assertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null,
"+(title:dog title:cat) -author:\"bob dole\"");
- QueryParser qp = new QueryParser("field", new StandardAnalyzer());
+ QueryParser qp = new QueryParser("field", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
// make sure OR is the default:
assertEquals(QueryParser.OR_OPERATOR, qp.getDefaultOperator());
qp.setDefaultOperator(QueryParser.AND_OPERATOR);
@@ -321,7 +321,7 @@ public class TestQueryParser extends LocalizedTestCase {
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new StandardAnalyzer();
+ Analyzer a = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -791,7 +791,7 @@ public class TestQueryParser extends LocalizedTestCase {
throws Exception {
Set stopWords = new HashSet(1);
stopWords.add("on");
- StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(stopWords);
+ StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, stopWords);
QueryParser qp = new QueryParser("field", oneStopAnalyzer);
Query q = qp.parse("on^1.0");
assertNotNull(q);
@@ -804,7 +804,7 @@ public class TestQueryParser extends LocalizedTestCase {
q = qp.parse("\"on\"^1.0");
assertNotNull(q);
- QueryParser qp2 = new QueryParser("field", new StandardAnalyzer());
+ QueryParser qp2 = new QueryParser("field", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
q = qp2.parse("the^3");
// "the" is a stop word so the result is an empty query:
assertNotNull(q);
@@ -944,7 +944,7 @@ public class TestQueryParser extends LocalizedTestCase {
}
public void testStopwords() throws Exception {
- QueryParser qp = new QueryParser("a", new StopAnalyzer(new String[]{"the", "foo"}));
+ QueryParser qp = new QueryParser("a", new StopAnalyzer(StopFilter.makeStopSet("the", "foo"), true));
Query result = qp.parse("a:the OR a:foo");
assertNotNull("result is null and it shouldn't be", result);
assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
@@ -960,25 +960,19 @@ public class TestQueryParser extends LocalizedTestCase {
}
public void testPositionIncrement() throws Exception {
- boolean dflt = StopFilter.getEnablePositionIncrementsDefault();
- StopFilter.setEnablePositionIncrementsDefault(true);
- try {
- QueryParser qp = new QueryParser("a", new StopAnalyzer(new String[]{"the", "in", "are", "this"}));
- qp.setEnablePositionIncrements(true);
- String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
- // 0 2 5 7 8
- int expectedPositions[] = {1,3,4,6,9};
- PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
- //System.out.println("Query text: "+qtxt);
- //System.out.println("Result: "+pq);
- Term t[] = pq.getTerms();
- int pos[] = pq.getPositions();
- for (int i = 0; i < t.length; i++) {
- //System.out.println(i+". "+t[i]+" pos: "+pos[i]);
- assertEquals("term "+i+" = "+t[i]+" has wrong term-position!",expectedPositions[i],pos[i]);
- }
- } finally {
- StopFilter.setEnablePositionIncrementsDefault(dflt);
+ QueryParser qp = new QueryParser("a", new StopAnalyzer(StopFilter.makeStopSet("the", "in", "are", "this"), true));
+ qp.setEnablePositionIncrements(true);
+ String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
+ // 0 2 5 7 8
+ int expectedPositions[] = {1,3,4,6,9};
+ PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
+ //System.out.println("Query text: "+qtxt);
+ //System.out.println("Result: "+pq);
+ Term t[] = pq.getTerms();
+ int pos[] = pq.getPositions();
+ for (int i = 0; i < t.length; i++) {
+ //System.out.println(i+". "+t[i]+" pos: "+pos[i]);
+ assertEquals("term "+i+" = "+t[i]+" has wrong term-position!",expectedPositions[i],pos[i]);
}
}
diff --git a/src/test/org/apache/lucene/search/TestBooleanOr.java b/src/test/org/apache/lucene/search/TestBooleanOr.java
index 11c63968322..4ec8dbcc113 100644
--- a/src/test/org/apache/lucene/search/TestBooleanOr.java
+++ b/src/test/org/apache/lucene/search/TestBooleanOr.java
@@ -135,7 +135,7 @@ public class TestBooleanOr extends LuceneTestCase {
RAMDirectory rd = new RAMDirectory();
//
- IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
//
Document d = new Document();
diff --git a/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java b/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
index 1718d017d7e..a0f55ea8918 100644
--- a/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
+++ b/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
@@ -32,7 +32,7 @@ import org.apache.lucene.util.OpenBitSetDISI;
public class TestCachingWrapperFilter extends LuceneTestCase {
public void testCachingWorks() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.close();
IndexReader reader = IndexReader.open(dir, true);
@@ -71,7 +71,7 @@ public class TestCachingWrapperFilter extends LuceneTestCase {
public void testIsCacheAble() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.close();
IndexReader reader = IndexReader.open(dir, true);
diff --git a/src/test/org/apache/lucene/search/TestCustomSearcherSort.java b/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
index 56acd5be5a6..eb3f7c750e1 100644
--- a/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
+++ b/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
@@ -70,7 +70,7 @@ implements Serializable {
private Directory getIndex()
throws IOException {
RAMDirectory indexStore = new RAMDirectory ();
- IndexWriter writer = new IndexWriter (indexStore, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter (indexStore, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
RandomGen random = new RandomGen(newRandom());
for (int i=0; i<INDEX_SIZE; ++i) { // don't decrease; if to low the problem doesn't show up
Document doc = new Document();
diff --git a/src/test/org/apache/lucene/search/TestFuzzyQuery.java b/src/test/org/apache/lucene/search/TestFuzzyQuery.java
index 2488bbe0311..d7f2b2e68ea 100644
--- a/src/test/org/apache/lucene/search/TestFuzzyQuery.java
+++ b/src/test/org/apache/lucene/search/TestFuzzyQuery.java
@@ -288,7 +288,7 @@ public class TestFuzzyQuery extends LuceneTestCase {
public void testGiga() throws Exception {
- StandardAnalyzer analyzer = new StandardAnalyzer();
+ StandardAnalyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
Directory index = new MockRAMDirectory();
IndexWriter w = new IndexWriter(index, analyzer, true, IndexWriter.MaxFieldLength.UNLIMITED);
diff --git a/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java b/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
index 30ddeba69ce..c92af488b25 100644
--- a/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
+++ b/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
@@ -33,6 +33,7 @@ import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
+import java.util.Collections;
/**
* This class tests the MultiPhraseQuery class.
@@ -169,7 +170,7 @@ public class TestMultiPhraseQuery extends LuceneTestCase
public void testPhrasePrefixWithBooleanQuery() throws IOException {
RAMDirectory indexStore = new RAMDirectory();
- IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(new HashSet(0)), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.emptySet()), true, IndexWriter.MaxFieldLength.LIMITED);
add("This is a test", "object", writer);
add("a note", "note", writer);
writer.close();
diff --git a/src/test/org/apache/lucene/search/TestMultiSearcher.java b/src/test/org/apache/lucene/search/TestMultiSearcher.java
index 38107406006..8244d54f77d 100644
--- a/src/test/org/apache/lucene/search/TestMultiSearcher.java
+++ b/src/test/org/apache/lucene/search/TestMultiSearcher.java
@@ -82,9 +82,9 @@ public class TestMultiSearcher extends LuceneTestCase
lDoc3.add(new Field("handle", "1", Field.Store.YES, Field.Index.NOT_ANALYZED));
// creating an index writer for the first index
- IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
// creating an index writer for the second index, but writing nothing
- IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
//--------------------------------------------------------------------
// scenario 1
@@ -101,7 +101,7 @@ public class TestMultiSearcher extends LuceneTestCase
writerB.close();
// creating the query
- QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
+ QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query query = parser.parse("handle:1");
// building the searchables
@@ -128,7 +128,7 @@ public class TestMultiSearcher extends LuceneTestCase
//--------------------------------------------------------------------
// adding one document to the empty index
- writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writerB.addDocument(lDoc);
writerB.optimize();
writerB.close();
@@ -174,7 +174,7 @@ public class TestMultiSearcher extends LuceneTestCase
readerB.close();
// optimizing the index with the writer
- writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writerB.optimize();
writerB.close();
diff --git a/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java b/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
index ef313bec3bf..2c1253c984a 100644
--- a/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
+++ b/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
@@ -87,7 +87,7 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
private void checkQuery(String queryStr) throws IOException, ParseException {
// check result hit ranking
if(verbose) System.out.println("Query: " + queryStr);
- QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+ QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query query = queryParser.parse(queryStr);
ScoreDoc[] multiSearcherHits = multiSearcher.search(query, null, 1000).scoreDocs;
ScoreDoc[] singleSearcherHits = singleSearcher.search(query, null, 1000).scoreDocs;
@@ -113,12 +113,12 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
super.setUp();
// create MultiSearcher from two seperate searchers
Directory d1 = new RAMDirectory();
- IndexWriter iw1 = new IndexWriter(d1, new StandardAnalyzer(), true,
+ IndexWriter iw1 = new IndexWriter(d1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
addCollection1(iw1);
iw1.close();
Directory d2 = new RAMDirectory();
- IndexWriter iw2 = new IndexWriter(d2, new StandardAnalyzer(), true,
+ IndexWriter iw2 = new IndexWriter(d2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
addCollection2(iw2);
iw2.close();
@@ -130,7 +130,7 @@ public class TestMultiSearcherRanking extends LuceneTestCase {
// create IndexSearcher which contains all documents
Directory d = new RAMDirectory();
- IndexWriter iw = new IndexWriter(d, new StandardAnalyzer(), true,
+ IndexWriter iw = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
addCollection1(iw);
addCollection2(iw);
diff --git a/src/test/org/apache/lucene/search/TestPhraseQuery.java b/src/test/org/apache/lucene/search/TestPhraseQuery.java
index 0939aab579b..4367639d44d 100644
--- a/src/test/org/apache/lucene/search/TestPhraseQuery.java
+++ b/src/test/org/apache/lucene/search/TestPhraseQuery.java
@@ -201,7 +201,7 @@ public class TestPhraseQuery extends LuceneTestCase {
public void testPhraseQueryWithStopAnalyzer() throws Exception {
RAMDirectory directory = new RAMDirectory();
- StopAnalyzer stopAnalyzer = new StopAnalyzer();
+ StopAnalyzer stopAnalyzer = new StopAnalyzer(false);
IndexWriter writer = new IndexWriter(directory, stopAnalyzer, true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -357,8 +357,7 @@ public class TestPhraseQuery extends LuceneTestCase {
}
public void testToString() throws Exception {
- StopAnalyzer analyzer = new StopAnalyzer();
- StopFilter.setEnablePositionIncrementsDefault(true);
+ StopAnalyzer analyzer = new StopAnalyzer(true);
QueryParser qp = new QueryParser("field", analyzer);
qp.setEnablePositionIncrements(true);
PhraseQuery q = (PhraseQuery)qp.parse("\"this hi this is a test is\"");
diff --git a/src/test/org/apache/lucene/search/TestPositionIncrement.java b/src/test/org/apache/lucene/search/TestPositionIncrement.java
index 36f6ba1f944..680f785f737 100644
--- a/src/test/org/apache/lucene/search/TestPositionIncrement.java
+++ b/src/test/org/apache/lucene/search/TestPositionIncrement.java
@@ -21,6 +21,7 @@ import java.io.Reader;
import java.io.IOException;
import java.io.StringReader;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import org.apache.lucene.analysis.Analyzer;
@@ -31,6 +32,7 @@ import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.CharArraySet;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
@@ -226,7 +228,7 @@ public class TestPositionIncrement extends BaseTokenStreamTestCase {
}
public TokenStream tokenStream(String fieldName, Reader reader) {
TokenStream ts = a.tokenStream(fieldName,reader);
- return new StopFilter(enablePositionIncrements, ts, new String[]{"stop"});
+ return new StopFilter(enablePositionIncrements, ts, new CharArraySet(Collections.singleton("stop"), true));
}
}
diff --git a/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java b/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
index c8e7c602e2f..857167056f7 100644
--- a/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
+++ b/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
@@ -33,7 +33,7 @@ public class TestQueryWrapperFilter extends LuceneTestCase {
public void testBasic() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true,
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
doc.add(new Field("field", "value", Store.NO, Index.ANALYZED));
diff --git a/src/test/org/apache/lucene/search/TestSimpleExplanations.java b/src/test/org/apache/lucene/search/TestSimpleExplanations.java
index 7f12ddbeb37..cb6db38e6f1 100644
--- a/src/test/org/apache/lucene/search/TestSimpleExplanations.java
+++ b/src/test/org/apache/lucene/search/TestSimpleExplanations.java
@@ -316,8 +316,8 @@ public class TestSimpleExplanations extends TestExplanations {
Document lDoc3 = new Document();
lDoc3.add(new Field("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
- IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
- IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writerA.addDocument(lDoc);
writerA.addDocument(lDoc2);
@@ -327,7 +327,7 @@ public class TestSimpleExplanations extends TestExplanations {
writerB.addDocument(lDoc3);
writerB.close();
- QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
+ QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query query = parser.parse("handle:1");
Searcher[] searchers = new Searcher[2];
diff --git a/src/test/org/apache/lucene/search/TestStressSort.java b/src/test/org/apache/lucene/search/TestStressSort.java
index d8e1b81e5be..814d6275c74 100644
--- a/src/test/org/apache/lucene/search/TestStressSort.java
+++ b/src/test/org/apache/lucene/search/TestStressSort.java
@@ -72,7 +72,7 @@ public class TestStressSort extends LuceneTestCase {
// deterministic, but do not commit with a seed (to
// better test):
dir = new MockRAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
writer.setMaxBufferedDocs(17);
final Document doc = new Document();
@@ -169,13 +169,13 @@ public class TestStressSort extends LuceneTestCase {
searcherMultiSegment.setDefaultFieldSortScoring(true, true);
dir2 = new MockRAMDirectory(dir);
- writer = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
writer.optimize();
writer.close();
searcherSingleSegment = new IndexSearcher(dir2, true);
searcherSingleSegment.setDefaultFieldSortScoring(true, true);
dir3 = new MockRAMDirectory(dir);
- writer = new IndexWriter(dir3, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ writer = new IndexWriter(dir3, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
writer.optimize(3);
writer.close();
searcherFewSegment = new IndexSearcher(dir3, true);
diff --git a/src/test/org/apache/lucene/search/function/FunctionTestSetup.java b/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
index 704145511c0..247b30c5f4f 100755
--- a/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
+++ b/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
@@ -86,7 +86,7 @@ public abstract class FunctionTestSetup extends LuceneTestCase {
// prepare a small index with just a few documents.
super.setUp();
dir = new RAMDirectory();
- anlzr = new StandardAnalyzer();
+ anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter iw = new IndexWriter(dir, anlzr,
IndexWriter.MaxFieldLength.LIMITED);
// add docs not exactly in natural ID order, to verify we do check the order of docs by scores
diff --git a/src/test/org/apache/lucene/search/spans/TestSpans.java b/src/test/org/apache/lucene/search/spans/TestSpans.java
index 6acff60bea3..298ebd426d9 100644
--- a/src/test/org/apache/lucene/search/spans/TestSpans.java
+++ b/src/test/org/apache/lucene/search/spans/TestSpans.java
@@ -39,7 +39,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
-import java.util.HashSet;
+import java.util.Collections;
public class TestSpans extends LuceneTestCase {
private IndexSearcher searcher;
@@ -449,7 +449,7 @@ public class TestSpans extends LuceneTestCase {
// LUCENE-1404
public void testNPESpanQuery() throws Throwable {
final Directory dir = new MockRAMDirectory();
- final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(new HashSet(0)), IndexWriter.MaxFieldLength.LIMITED);
+ final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.emptySet()), IndexWriter.MaxFieldLength.LIMITED);
// Add documents
addDoc(writer, "1", "the big dogs went running to the market");
diff --git a/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java b/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
index afa3667ff33..2d0bb99c3eb 100644
--- a/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
+++ b/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
@@ -55,7 +55,7 @@ public class TestSpansAdvanced extends LuceneTestCase {
// create test index
mDirectory = new RAMDirectory();
- final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDocument(writer, "1", "I think it should work.");
addDocument(writer, "2", "I think it should work.");
addDocument(writer, "3", "I think it should work.");
diff --git a/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java b/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
index 212652473fb..a39a0458bdb 100644
--- a/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
+++ b/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
@@ -39,7 +39,7 @@ public class TestSpansAdvanced2 extends TestSpansAdvanced {
super.setUp();
// create test index
- final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
addDocument(writer, "A", "Should we, could we, would we?");
addDocument(writer, "B", "It should. Should it?");
addDocument(writer, "C", "It shouldn't.");
diff --git a/src/test/org/apache/lucene/store/TestWindowsMMap.java b/src/test/org/apache/lucene/store/TestWindowsMMap.java
index 382fb7e83c0..21063e86e21 100644
--- a/src/test/org/apache/lucene/store/TestWindowsMMap.java
+++ b/src/test/org/apache/lucene/store/TestWindowsMMap.java
@@ -17,7 +17,7 @@ package org.apache.lucene.store;
* limitations under the License.
*/
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Random;
import java.io.File;
@@ -68,7 +68,7 @@ public class TestWindowsMMap extends LuceneTestCase {
// plan to add a set of useful stopwords, consider changing some of the
// interior filters.
- StandardAnalyzer analyzer = new StandardAnalyzer(new HashSet());
+ StandardAnalyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.emptySet());
// TODO: something about lock timeouts and leftover locks.
IndexWriter writer = new IndexWriter(storeDirectory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
IndexSearcher searcher = new IndexSearcher(storeDirectory, true);