Index: solr/src/test/test-files/solr/conf/schema-luceneMatchVersion.xml
===================================================================
--- solr/src/test/test-files/solr/conf/schema-luceneMatchVersion.xml (revision 1040383)
+++ solr/src/test/test-files/solr/conf/schema-luceneMatchVersion.xml (working copy)
@@ -18,12 +18,12 @@
*/
public final class BulgarianAnalyzer extends StopwordAnalyzerBase {
-
/**
* File containing default Bulgarian stopwords.
*
@@ -53,17 +50,8 @@
* BSD-Licensed.
*/
public final static String DEFAULT_STOPWORD_FILE = "stopwords.txt";
-
+
/**
- * The comment character in the stopwords file. All lines prefixed with this
- * will be ignored
- * @deprecated use {@link WordlistLoader#getWordSet(File, String)} directly
- */
- //TODO make this private
- @Deprecated
- public static final String STOPWORDS_COMMENT = "#";
-
- /**
* Returns an unmodifiable instance of the default stop-words set.
*
* @return an unmodifiable instance of the default stop-words set.
@@ -81,7 +69,7 @@
static {
try {
- DEFAULT_STOP_SET = loadStopwordSet(false, BulgarianAnalyzer.class, DEFAULT_STOPWORD_FILE, STOPWORDS_COMMENT);
+ DEFAULT_STOP_SET = loadStopwordSet(false, BulgarianAnalyzer.class, DEFAULT_STOPWORD_FILE, "#");
} catch (IOException ex) {
// default set should always be present as it is part of the
// distribution (JAR)
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseTokenizer.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseTokenizer.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseTokenizer.java (working copy)
@@ -89,40 +89,6 @@
super(matchVersion, factory, in);
}
- /**
- * Construct a new LowerCaseTokenizer.
- *
- * @deprecated use {@link #LowerCaseTokenizer(Reader)} instead. This will be
- * removed in Lucene 4.0.
- */
- @Deprecated
- public LowerCaseTokenizer(Reader in) {
- super(Version.LUCENE_30, in);
- }
-
- /**
- * Construct a new LowerCaseTokenizer using a given {@link AttributeSource}.
- *
- * @deprecated use {@link #LowerCaseTokenizer(AttributeSource, Reader)}
- * instead. This will be removed in Lucene 4.0.
- */
- @Deprecated
- public LowerCaseTokenizer(AttributeSource source, Reader in) {
- super(Version.LUCENE_30, source, in);
- }
-
- /**
- * Construct a new LowerCaseTokenizer using a given
- * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}.
- *
- * @deprecated use {@link #LowerCaseTokenizer(AttributeSource.AttributeFactory, Reader)}
- * instead. This will be removed in Lucene 4.0.
- */
- @Deprecated
- public LowerCaseTokenizer(AttributeFactory factory, Reader in) {
- super(Version.LUCENE_30, factory, in);
- }
-
/** Converts char to lower case
* {@link Character#toLowerCase(int)}.*/
@Override
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/SimpleAnalyzer.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/SimpleAnalyzer.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/SimpleAnalyzer.java (working copy)
@@ -22,7 +22,6 @@
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.CharTokenizer;
import org.apache.lucene.analysis.util.ReusableAnalyzerBase;
-import org.apache.lucene.analysis.util.ReusableAnalyzerBase.TokenStreamComponents;
import org.apache.lucene.util.Version;
/** An {@link Analyzer} that filters {@link LetterTokenizer}
@@ -49,13 +48,6 @@
this.matchVersion = matchVersion;
}
- /**
- * Creates a new {@link SimpleAnalyzer}
- * @deprecated use {@link #SimpleAnalyzer(Version)} instead
- */
- @Deprecated public SimpleAnalyzer() {
- this(Version.LUCENE_30);
- }
@Override
protected TokenStreamComponents createComponents(final String fieldName,
final Reader reader) {
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceAnalyzer.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceAnalyzer.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceAnalyzer.java (working copy)
@@ -21,7 +21,6 @@
import org.apache.lucene.analysis.CharTokenizer;
import org.apache.lucene.analysis.util.ReusableAnalyzerBase;
-import org.apache.lucene.analysis.util.ReusableAnalyzerBase.TokenStreamComponents;
import org.apache.lucene.util.Version;
/**
@@ -48,15 +47,6 @@
this.matchVersion = matchVersion;
}
- /**
- * Creates a new {@link WhitespaceAnalyzer}
- * @deprecated use {@link #WhitespaceAnalyzer(Version)} instead
- */
- @Deprecated
- public WhitespaceAnalyzer() {
- this(Version.LUCENE_30);
- }
-
@Override
protected TokenStreamComponents createComponents(final String fieldName,
final Reader reader) {
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceTokenizer.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceTokenizer.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/WhitespaceTokenizer.java (working copy)
@@ -80,40 +80,6 @@
super(matchVersion, factory, in);
}
- /**
- * Construct a new WhitespaceTokenizer.
- *
- * @deprecated use {@link #WhitespaceTokenizer(Version, Reader)} instead. This will
- * be removed in Lucene 4.0.
- */
- @Deprecated
- public WhitespaceTokenizer(Reader in) {
- super(in);
- }
-
- /**
- * Construct a new WhitespaceTokenizer using a given {@link AttributeSource}.
- *
- * @deprecated use {@link #WhitespaceTokenizer(Version, AttributeSource, Reader)}
- * instead. This will be removed in Lucene 4.0.
- */
- @Deprecated
- public WhitespaceTokenizer(AttributeSource source, Reader in) {
- super(source, in);
- }
-
- /**
- * Construct a new WhitespaceTokenizer using a given
- * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}.
- *
- * @deprecated use {@link #WhitespaceTokenizer(Version, AttributeSource.AttributeFactory, Reader)}
- * instead. This will be removed in Lucene 4.0.
- */
- @Deprecated
- public WhitespaceTokenizer(AttributeFactory factory, Reader in) {
- super(factory, in);
- }
-
/** Collects only characters which do not satisfy
* {@link Character#isWhitespace(int)}.*/
@Override
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/LetterTokenizer.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/LetterTokenizer.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/LetterTokenizer.java (working copy)
@@ -87,40 +87,6 @@
super(matchVersion, factory, in);
}
- /**
- * Construct a new LetterTokenizer.
- *
- * @deprecated use {@link #LetterTokenizer(Version, Reader)} instead. This
- * will be removed in Lucene 4.0.
- */
- @Deprecated
- public LetterTokenizer(Reader in) {
- super(Version.LUCENE_30, in);
- }
-
- /**
- * Construct a new LetterTokenizer using a given {@link AttributeSource}.
- * @deprecated
- * use {@link #LetterTokenizer(Version, AttributeSource, Reader)} instead.
- * This will be removed in Lucene 4.0.
- */
- @Deprecated
- public LetterTokenizer(AttributeSource source, Reader in) {
- super(Version.LUCENE_30, source, in);
- }
-
- /**
- * Construct a new LetterTokenizer using a given
- * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}.
- *
- * @deprecated use {@link #LetterTokenizer(Version, AttributeSource.AttributeFactory, Reader)}
- * instead. This will be removed in Lucene 4.0.
- */
- @Deprecated
- public LetterTokenizer(AttributeFactory factory, Reader in) {
- super(Version.LUCENE_30, factory, in);
- }
-
/** Collects only characters which satisfy
* {@link Character#isLetter(int)}.*/
@Override
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseFilter.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseFilter.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/LowerCaseFilter.java (working copy)
@@ -49,14 +49,6 @@
charUtils = CharacterUtils.getInstance(matchVersion);
}
- /**
- * @deprecated Use {@link #LowerCaseFilter(Version, TokenStream)} instead.
- */
- @Deprecated
- public LowerCaseFilter(TokenStream in) {
- this(Version.LUCENE_30, in);
- }
-
@Override
public final boolean incrementToken() throws IOException {
if (input.incrementToken()) {
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/core/StopFilter.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/core/StopFilter.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/core/StopFilter.java (working copy)
@@ -19,15 +19,15 @@
import java.io.IOException;
import java.util.Arrays;
-import java.util.Set;
import java.util.List;
+import java.util.Set;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.util.CharArraySet;
-import org.apache.lucene.queryParser.QueryParser; // for javadoc
+import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.util.Version;
/**
@@ -45,35 +45,13 @@
public final class StopFilter extends TokenFilter {
private final CharArraySet stopWords;
- private boolean enablePositionIncrements = false;
+ private boolean enablePositionIncrements = true;
private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
+
/**
- * Construct a token stream filtering the given input.
- * If stopWords is an instance of {@link CharArraySet} (true if
- * makeStopSet() was used to construct the set) it will be directly used
- * and ignoreCase will be ignored since CharArraySet
- * directly controls case sensitivity.
- *
stopWords is not an instance of {@link CharArraySet},
- * a new CharArraySet will be constructed and ignoreCase will be
- * used to specify the case sensitivity of that set.
- *
- * @param enablePositionIncrements true if token positions should record the removed stop words
- * @param input Input TokenStream
- * @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
- * @deprecated use {@link #StopFilter(Version, TokenStream, Set, boolean)} instead
- */
- @Deprecated
- public StopFilter(boolean enablePositionIncrements, TokenStream input, Set> stopWords, boolean ignoreCase)
- {
- this(Version.LUCENE_30, enablePositionIncrements, input, stopWords, ignoreCase);
- }
-
- /**
* Construct a token stream filtering the given input. If
* stopWords is an instance of {@link CharArraySet} (true if
* makeStopSet() was used to construct the set) it will be
@@ -97,32 +75,9 @@
*/
public StopFilter(Version matchVersion, TokenStream input, Set> stopWords, boolean ignoreCase)
{
- this(matchVersion, matchVersion.onOrAfter(Version.LUCENE_29), input, stopWords, ignoreCase);
- }
-
- /*
- * convenience ctor to enable deprecated ctors to set posInc explicitly
- */
- private StopFilter(Version matchVersion, boolean enablePositionIncrements, TokenStream input, Set> stopWords, boolean ignoreCase){
super(input);
- this.stopWords = stopWords instanceof CharArraySet ? (CharArraySet)stopWords : new CharArraySet(matchVersion, stopWords, ignoreCase);
- this.enablePositionIncrements = enablePositionIncrements;
+ this.stopWords = stopWords instanceof CharArraySet ? (CharArraySet) stopWords : new CharArraySet(matchVersion, stopWords, ignoreCase);
}
-
- /**
- * Constructs a filter which removes words from the input
- * TokenStream that are named in the Set.
- *
- * @param enablePositionIncrements true if token positions should record the removed stop words
- * @param in Input stream
- * @param stopWords A Set of Strings or char[] or any other toString()-able set representing the stopwords
- * @see #makeStopSet(Version, java.lang.String[])
- * @deprecated use {@link #StopFilter(Version, TokenStream, Set)} instead
- */
- @Deprecated
- public StopFilter(boolean enablePositionIncrements, TokenStream in, Set> stopWords) {
- this(Version.LUCENE_CURRENT, enablePositionIncrements, in, stopWords, false);
- }
/**
* Constructs a filter which removes words from the input TokenStream that are
@@ -136,7 +91,7 @@
* @param stopWords
* A Set of Strings or char[] or any other toString()-able set
* representing the stopwords
- * @see #makeStopSet(Version, java.lang.String[])
+ * @see #makeStopSet(Version, java.lang.String...)
*/
public StopFilter(Version matchVersion, TokenStream in, Set> stopWords) {
this(matchVersion, in, stopWords, false);
@@ -148,25 +103,11 @@
* This permits this stopWords construction to be cached once when
* an Analyzer is constructed.
*
- * @see #makeStopSet(Version, java.lang.String[], boolean) passing false to ignoreCase
- * @deprecated use {@link #makeStopSet(Version, String...)} instead
- */
- @Deprecated
- public static final Settrue is best as it does not
* lose information (positions of the original tokens)
* during indexing.
+ *
+ * Default is true.
*
* When set, when a token is stopped
* (omitted), the position increment of the following
Index: modules/analysis/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java
===================================================================
--- modules/analysis/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java (revision 1040383)
+++ modules/analysis/common/src/java/org/apache/lucene/analysis/de/GermanAnalyzer.java (working copy)
@@ -18,12 +18,9 @@
* limitations under the License.
*/
-import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.apache.lucene.analysis.Analyzer;
@@ -67,13 +64,9 @@
*/
public final class GermanAnalyzer extends StopwordAnalyzerBase {
- /**
- * List of typical german stopwords.
- * @deprecated use {@link #getDefaultStopSet()} instead
- */
- //TODO make this private in 3.1, remove in 4.0
+ /** @deprecated in 3.1, remove in Lucene 5.0 (index bw compat) */
@Deprecated
- public final static String[] GERMAN_STOP_WORDS = {
+ private final static String[] GERMAN_STOP_WORDS = {
"einer", "eine", "eines", "einem", "einen",
"der", "die", "das", "dass", "daß",
"du", "er", "sie", "es",
@@ -100,7 +93,7 @@
}
private static class DefaultSetHolder {
- /** @deprecated remove in Lucene 4.0 */
+ /** @deprecated in 3.1, remove in Lucene 5.0 (index bw compat) */
@Deprecated
private static final Set> DEFAULT_SET_30 = CharArraySet.unmodifiableSet(new CharArraySet(
Version.LUCENE_CURRENT, Arrays.asList(GERMAN_STOP_WORDS), false));
@@ -124,8 +117,7 @@
/**
* Contains words that should be indexed but not stemmed.
*/
- // TODO make this final in 3.1
- private Set> exclusionSet;
+ private final Set> exclusionSet;
/**
* Builds an analyzer with the default stop words:
@@ -165,64 +157,6 @@
}
/**
- * Builds an analyzer with the given stop words.
- * @deprecated use {@link #GermanAnalyzer(Version, Set)}
- */
- @Deprecated
- public GermanAnalyzer(Version matchVersion, String... stopwords) {
- this(matchVersion, StopFilter.makeStopSet(matchVersion, stopwords));
- }
-
- /**
- * Builds an analyzer with the given stop words.
- * @deprecated use {@link #GermanAnalyzer(Version, Set)}
- */
- @Deprecated
- public GermanAnalyzer(Version matchVersion, Map,?> stopwords) {
- this(matchVersion, stopwords.keySet());
-
- }
-
- /**
- * Builds an analyzer with the given stop words.
- * @deprecated use {@link #GermanAnalyzer(Version, Set)}
- */
- @Deprecated
- public GermanAnalyzer(Version matchVersion, File stopwords) throws IOException {
- this(matchVersion, WordlistLoader.getWordSet(stopwords));
- }
-
- /**
- * Builds an exclusionlist from an array of Strings.
- * @deprecated use {@link #GermanAnalyzer(Version, Set, Set)} instead
- */
- @Deprecated
- public void setStemExclusionTable(String[] exclusionlist) {
- exclusionSet = StopFilter.makeStopSet(matchVersion, exclusionlist);
- setPreviousTokenStream(null); // force a new stemmer to be created
- }
-
- /**
- * Builds an exclusionlist from a {@link Map}
- * @deprecated use {@link #GermanAnalyzer(Version, Set, Set)} instead
- */
- @Deprecated
- public void setStemExclusionTable(Map,?> exclusionlist) {
- exclusionSet = new HashSet You must specify the required {@link Version}
- * compatibility when creating ClassicAnalyzer:
- *
* As of Lucene version 3.1, this class implements the Word Break rules from the
@@ -61,28 +61,25 @@
private StandardTokenizerInterface scanner;
public static final int ALPHANUM = 0;
- /** @deprecated */
+ /** @deprecated (3.1) */
@Deprecated
public static final int APOSTROPHE = 1;
- /** @deprecated */
+ /** @deprecated (3.1) */
@Deprecated
public static final int ACRONYM = 2;
- /** @deprecated */
+ /** @deprecated (3.1) */
@Deprecated
public static final int COMPANY = 3;
public static final int EMAIL = 4;
- /** @deprecated */
+ /** @deprecated (3.1) */
@Deprecated
public static final int HOST = 5;
public static final int NUM = 6;
- /** @deprecated */
+ /** @deprecated (3.1) */
@Deprecated
public static final int CJ = 7;
- /**
- * @deprecated this solves a bug where HOSTs that end with '.' are identified
- * as ACRONYMs.
- */
+ /** @deprecated (3.1) */
@Deprecated
public static final int ACRONYM_DEP = 8;
@@ -108,8 +105,6 @@
"
- * For instance, 'à' will be replaced by 'a'.
- *
- *
- * @deprecated If you build a new index, use {@link ASCIIFoldingFilter}
- * which covers a superset of Latin 1.
- * This class is included for use with existing
- * indexes and will be removed in a future release (possibly Lucene 4.0).
- */
-@Deprecated
-public final class ISOLatin1AccentFilter extends TokenFilter {
- public ISOLatin1AccentFilter(TokenStream input) {
- super(input);
- }
-
- private char[] output = new char[256];
- private int outputPos;
- private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
-
- @Override
- public final boolean incrementToken() throws java.io.IOException {
- if (input.incrementToken()) {
- final char[] buffer = termAtt.buffer();
- final int length = termAtt.length();
- // If no characters actually require rewriting then we
- // just return token as-is:
- for(int i=0;i
- *
- *
* ClassicTokenizer was named StandardTokenizer in Lucene versions prior to 3.1.
* As of 3.1, {@link StandardTokenizer} implements Unicode text segmentation,
* as specified by UAX#29.
@@ -70,13 +62,8 @@
public static final int NUM = 6;
public static final int CJ = 7;
- /**
- * @deprecated this solves a bug where HOSTs that end with '.' are identified
- * as ACRONYMs.
- */
- @Deprecated
public static final int ACRONYM_DEP = 8;
-
+
/** String token types that correspond to token type int constants */
public static final String [] TOKEN_TYPES = new String [] {
"
- * The reversed tokens will be prepended (marked) by the marker
- * character.
- *
- * The reversed tokens will not be marked. - *
- * * @param matchVersion See above * @param in {@link TokenStream} to filter */ @@ -153,19 +119,6 @@ /** * Reverses the given input string * - * @param input the string to reverse - * @return the given input string in reversed order - * @deprecated use {@link #reverse(Version, String)} instead. This method - * will be removed in Lucene 4.0 - */ - @Deprecated - public static String reverse( final String input ){ - return reverse(Version.LUCENE_30, input); - } - - /** - * Reverses the given input string - * * @param matchVersion See above * @param input the string to reverse * @return the given input string in reversed order @@ -178,17 +131,6 @@ /** * Reverses the given input buffer in-place - * @param buffer the input char array to reverse - * @deprecated use {@link #reverse(Version, char[])} instead. This - * method will be removed in Lucene 4.0 - */ - @Deprecated - public static void reverse( final char[] buffer ){ - reverse( buffer, 0, buffer.length ); - } - - /** - * Reverses the given input buffer in-place * @param matchVersion See above * @param buffer the input char array to reverse */ @@ -199,20 +141,6 @@ /** * Partially reverses the given input buffer in-place from offset 0 * up to the given length. - * @param buffer the input char array to reverse - * @param len the length in the buffer up to where the - * buffer should be reversed - * @deprecated use {@link #reverse(Version, char[], int)} instead. This - * method will be removed in Lucene 4.0 - */ - @Deprecated - public static void reverse( final char[] buffer, final int len ){ - reverse( buffer, 0, len ); - } - - /** - * Partially reverses the given input buffer in-place from offset 0 - * up to the given length. * @param matchVersion See above * @param buffer the input char array to reverse * @param len the length in the buffer up to where the @@ -224,24 +152,9 @@ } /** - * Partially reverses the given input buffer in-place from the given offset - * up to the given length. - * @param buffer the input char array to reverse - * @param start the offset from where to reverse the buffer - * @param len the length in the buffer up to where the - * buffer should be reversed - * @deprecated use {@link #reverse(Version, char[], int, int)} instead. This - * method will be removed in Lucene 4.0 + * @deprecated (3.1) Remove this when support for 3.0 indexes is no longer needed. */ @Deprecated - public static void reverse(char[] buffer, int start, int len ) { - reverseUnicode3(buffer, start, len); - } - - /** - * @deprecated Remove this when support for 3.0 indexes is no longer needed. - */ - @Deprecated private static void reverseUnicode3( char[] buffer, int start, int len ){ if( len <= 1 ) return; int num = len>>1; Index: modules/analysis/common/src/java/org/apache/lucene/analysis/payloads/IdentityEncoder.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/payloads/IdentityEncoder.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/payloads/IdentityEncoder.java (working copy) @@ -28,23 +28,15 @@ * **/ public class IdentityEncoder extends AbstractEncoder implements PayloadEncoder{ - protected Charset charset = Charset.forName("UTF-8"); - /** @deprecated This field is no longer used. Use {@link #charset} instead. */ - @Deprecated - protected String charsetName = charset.name(); - public IdentityEncoder() { } public IdentityEncoder(Charset charset) { this.charset = charset; - // @deprecated, remove this in 4.0: - charsetName = charset.name(); } - public Payload encode(char[] buffer, int offset, int length) { final ByteBuffer bb = charset.encode(CharBuffer.wrap(buffer, offset, length)); if (bb.hasArray()) { Index: modules/analysis/common/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/snowball/SnowballAnalyzer.java (working copy) @@ -24,9 +24,9 @@ import org.apache.lucene.analysis.standard.*; import org.apache.lucene.analysis.tr.TurkishLowerCaseFilter; import org.apache.lucene.analysis.util.CharArraySet; +import org.apache.lucene.analysis.util.ReusableAnalyzerBase; import org.apache.lucene.util.Version; -import java.io.IOException; import java.io.Reader; import java.util.Set; @@ -43,11 +43,11 @@ *- * The implementation was inspired by GermanStemFilter. - * The input should be filtered by {@link LowerCaseFilter} before passing it to RussianStemFilter , - * because RussianStemFilter only works with lowercase characters. - *
- *- * To prevent terms from being stemmed use an instance of - * {@link KeywordMarkerFilter} or a custom {@link TokenFilter} that sets - * the {@link KeywordAttribute} before this {@link TokenStream}. - *
- * @see KeywordMarkerFilter - * @deprecated Use {@link SnowballFilter} with - * {@link org.tartarus.snowball.ext.RussianStemmer} instead, which has the - * same functionality. This filter will be removed in Lucene 4.0 - */ -@Deprecated -public final class RussianStemFilter extends TokenFilter -{ - /** - * The actual token in the input stream. - */ - private RussianStemmer stemmer = new RussianStemmer(); - - private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class); - private final KeywordAttribute keywordAttr = addAttribute(KeywordAttribute.class); - - public RussianStemFilter(TokenStream in) - { - super(in); - } - /** - * Returns the next token in the stream, or null at EOS - */ - @Override - public final boolean incrementToken() throws IOException - { - if (input.incrementToken()) { - if(!keywordAttr.isKeyword()) { - final String term = termAtt.toString(); - final String s = stemmer.stem(term); - if (s != null && !s.equals(term)) - termAtt.setEmpty().append(s); - } - return true; - } else { - return false; - } - } - - - /** - * Set a alternative/custom {@link RussianStemmer} for this filter. - */ - public void setStemmer(RussianStemmer stemmer) - { - if (stemmer != null) - { - this.stemmer = stemmer; - } - } -} Index: modules/analysis/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/ru/RussianAnalyzer.java (working copy) @@ -20,7 +20,6 @@ import java.io.IOException; import java.io.Reader; import java.util.Arrays; -import java.util.Map; import java.util.Set; import org.apache.lucene.analysis.Analyzer; @@ -56,7 +55,7 @@ { /** * List of typical Russian stopwords. (for backwards compatibility) - * @deprecated Remove this for LUCENE 4.0 + * @deprecated (3.1) Remove this for LUCENE 5.0 */ @Deprecated private static final String[] RUSSIAN_STOP_WORDS_30 = { @@ -76,7 +75,7 @@ public final static String DEFAULT_STOPWORD_FILE = "russian_stop.txt"; private static class DefaultSetHolder { - /** @deprecated remove this for Lucene 4.0 */ + /** @deprecated (3.1) remove this for Lucene 5.0 */ @Deprecated static final Set> DEFAULT_STOP_SET_30 = CharArraySet .unmodifiableSet(new CharArraySet(Version.LUCENE_CURRENT, @@ -113,15 +112,6 @@ } /** - * Builds an analyzer with the given stop words. - * @deprecated use {@link #RussianAnalyzer(Version, Set)} instead - */ - @Deprecated - public RussianAnalyzer(Version matchVersion, String... stopwords) { - this(matchVersion, StopFilter.makeStopSet(matchVersion, stopwords)); - } - - /** * Builds an analyzer with the given stop words * * @param matchVersion @@ -147,18 +137,6 @@ this.stemExclusionSet = CharArraySet.unmodifiableSet(CharArraySet.copy(matchVersion, stemExclusionSet)); } - - /** - * Builds an analyzer with the given stop words. - * TODO: create a Set version of this ctor - * @deprecated use {@link #RussianAnalyzer(Version, Set)} instead - */ - @Deprecated - public RussianAnalyzer(Version matchVersion, Map,?> stopwords) - { - this(matchVersion, stopwords.keySet()); - } - /** * Creates * {@link org.apache.lucene.analysis.util.ReusableAnalyzerBase.TokenStreamComponents} @@ -188,7 +166,8 @@ result = new StopFilter(matchVersion, result, stopwords); if (!stemExclusionSet.isEmpty()) result = new KeywordMarkerFilter( result, stemExclusionSet); - return new TokenStreamComponents(source, new RussianStemFilter(result)); + result = new SnowballFilter(result, new org.tartarus.snowball.ext.RussianStemmer()); + return new TokenStreamComponents(source, result); } } } Index: modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseAnalyzer.java (working copy) @@ -27,8 +27,8 @@ /** * An {@link Analyzer} that tokenizes text with {@link ChineseTokenizer} and * filters with {@link ChineseFilter} - * @deprecated Use {@link StandardAnalyzer} instead, which has the same functionality. - * This analyzer will be removed in Lucene 4.0 + * @deprecated (3.1) Use {@link StandardAnalyzer} instead, which has the same functionality. + * This analyzer will be removed in Lucene 5.0 */ @Deprecated public final class ChineseAnalyzer extends ReusableAnalyzerBase { Index: modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseFilter.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseFilter.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseFilter.java (working copy) @@ -42,8 +42,8 @@ * * * @version 1.0 - * @deprecated Use {@link StopFilter} instead, which has the same functionality. - * This filter will be removed in Lucene 4.0 + * @deprecated (3.1) Use {@link StopFilter} instead, which has the same functionality. + * This filter will be removed in Lucene 5.0 */ @Deprecated public final class ChineseFilter extends TokenFilter { Index: modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseTokenizer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseTokenizer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/cn/ChineseTokenizer.java (working copy) @@ -53,8 +53,8 @@ * CJKTokenizer will not work. * * @version 1.0 - * @deprecated Use {@link StandardTokenizer} instead, which has the same functionality. - * This filter will be removed in Lucene 4.0 + * @deprecated (3.1) Use {@link StandardTokenizer} instead, which has the same functionality. + * This filter will be removed in Lucene 5.0 */ @Deprecated public final class ChineseTokenizer extends Tokenizer { Index: modules/analysis/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/el/GreekAnalyzer.java (working copy) @@ -16,21 +16,20 @@ * limitations under the License. */ +import java.io.IOException; +import java.io.Reader; +import java.util.Set; + import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.StopFilter; +import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardFilter; import org.apache.lucene.analysis.standard.StandardTokenizer; -import org.apache.lucene.analysis.standard.StandardAnalyzer; // for javadoc import org.apache.lucene.analysis.util.StopwordAnalyzerBase; import org.apache.lucene.util.Version; -import java.io.IOException; -import java.io.Reader; -import java.util.Map; -import java.util.Set; - /** * {@link Analyzer} for the Greek language. *@@ -101,25 +100,6 @@ } /** - * Builds an analyzer with the given stop words. - * @param stopwords Array of stopwords to use. - * @deprecated use {@link #GreekAnalyzer(Version, Set)} instead - */ - @Deprecated - public GreekAnalyzer(Version matchVersion, String... stopwords) { - this(matchVersion, StopFilter.makeStopSet(matchVersion, stopwords)); - } - - /** - * Builds an analyzer with the given stop words. - * @deprecated use {@link #GreekAnalyzer(Version, Set)} instead - */ - @Deprecated - public GreekAnalyzer(Version matchVersion, Map,?> stopwords) { - this(matchVersion, stopwords.keySet()); - } - - /** * Creates * {@link org.apache.lucene.analysis.util.ReusableAnalyzerBase.TokenStreamComponents} * used to tokenize all the text in the provided {@link Reader}. Index: modules/analysis/common/src/java/org/apache/lucene/analysis/el/GreekLowerCaseFilter.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/el/GreekLowerCaseFilter.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/el/GreekLowerCaseFilter.java (working copy) @@ -38,12 +38,6 @@ private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class); private final CharacterUtils charUtils; - /** @deprecated Use {@link #GreekLowerCaseFilter(Version, TokenStream)} instead. */ - @Deprecated - public GreekLowerCaseFilter(TokenStream in) { - this(Version.LUCENE_30, in); - } - /** * Create a GreekLowerCaseFilter that normalizes Greek token text. * Index: modules/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicAnalyzer.java (working copy) @@ -62,14 +62,6 @@ public final static String DEFAULT_STOPWORD_FILE = "stopwords.txt"; /** - * The comment character in the stopwords file. All lines prefixed with this will be ignored - * @deprecated use {@link WordlistLoader#getWordSet(File, String)} directly - */ - // TODO make this private - @Deprecated - public static final String STOPWORDS_COMMENT = "#"; - - /** * Returns an unmodifiable instance of the default stop-words set. * @return an unmodifiable instance of the default stop-words set. */ @@ -86,7 +78,7 @@ static { try { - DEFAULT_STOP_SET = loadStopwordSet(false, ArabicAnalyzer.class, DEFAULT_STOPWORD_FILE, STOPWORDS_COMMENT); + DEFAULT_STOP_SET = loadStopwordSet(false, ArabicAnalyzer.class, DEFAULT_STOPWORD_FILE, "#"); } catch (IOException ex) { // default set should always be present as it is part of the // distribution (JAR) @@ -135,33 +127,6 @@ } /** - * Builds an analyzer with the given stop words. - * @deprecated use {@link #ArabicAnalyzer(Version, Set)} instead - */ - @Deprecated - public ArabicAnalyzer( Version matchVersion, String... stopwords ) { - this(matchVersion, StopFilter.makeStopSet(matchVersion, stopwords )); - } - - /** - * Builds an analyzer with the given stop words. - * @deprecated use {@link #ArabicAnalyzer(Version, Set)} instead - */ - @Deprecated - public ArabicAnalyzer( Version matchVersion, Hashtable,?> stopwords ) { - this(matchVersion, stopwords.keySet()); - } - - /** - * Builds an analyzer with the given stop words. Lines can be commented out using {@link #STOPWORDS_COMMENT} - * @deprecated use {@link #ArabicAnalyzer(Version, Set)} instead - */ - @Deprecated - public ArabicAnalyzer( Version matchVersion, File stopwords ) throws IOException { - this(matchVersion, WordlistLoader.getWordSet( stopwords, STOPWORDS_COMMENT)); - } - - /** * Creates * {@link org.apache.lucene.analysis.util.ReusableAnalyzerBase.TokenStreamComponents} * used to tokenize all the text in the provided {@link Reader}. Index: modules/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicLetterTokenizer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicLetterTokenizer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/ar/ArabicLetterTokenizer.java (working copy) @@ -40,8 +40,6 @@ * */ public class ArabicLetterTokenizer extends LetterTokenizer { - - /** * Construct a new ArabicLetterTokenizer. * @param matchVersion Lucene version @@ -84,41 +82,6 @@ } /** - * Construct a new ArabicLetterTokenizer. - * - * @deprecated use {@link #ArabicLetterTokenizer(Version, Reader)} instead. This will - * be removed in Lucene 4.0. - */ - @Deprecated - public ArabicLetterTokenizer(Reader in) { - super(in); - } - - /** - * Construct a new ArabicLetterTokenizer using a given {@link AttributeSource}. - * - * @deprecated use {@link #ArabicLetterTokenizer(Version, AttributeSource, Reader)} - * instead. This will be removed in Lucene 4.0. - */ - @Deprecated - public ArabicLetterTokenizer(AttributeSource source, Reader in) { - super(source, in); - } - - /** - * Construct a new ArabicLetterTokenizer using a given - * {@link org.apache.lucene.util.AttributeSource.AttributeFactory}. - * - * @deprecated use {@link #ArabicLetterTokenizer(Version, AttributeSource.AttributeFactory, Reader)} - * instead. This will be removed in Lucene 4.0. - */ - @Deprecated - public ArabicLetterTokenizer(AttributeFactory factory, Reader in) { - super(factory, in); - } - - - /** * Allows for Letter category or NonspacingMark category * @see org.apache.lucene.analysis.core.LetterTokenizer#isTokenChar(int) */ Index: modules/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/en/EnglishAnalyzer.java (working copy) @@ -21,11 +21,11 @@ import java.util.Set; import org.apache.lucene.analysis.Analyzer; +import org.apache.lucene.analysis.TokenStream; +import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.LowerCaseFilter; import org.apache.lucene.analysis.core.StopFilter; import org.apache.lucene.analysis.miscellaneous.KeywordMarkerFilter; -import org.apache.lucene.analysis.TokenStream; -import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.analysis.standard.StandardFilter; import org.apache.lucene.analysis.standard.StandardTokenizer; @@ -103,7 +103,7 @@ protected TokenStreamComponents createComponents(String fieldName, Reader reader) { final Tokenizer source = new StandardTokenizer(matchVersion, reader); - TokenStream result = new StandardFilter(source); + TokenStream result = new StandardFilter(matchVersion, source); // prior to this we get the classic behavior, standardfilter does it for us. if (matchVersion.onOrAfter(Version.LUCENE_31)) result = new EnglishPossessiveFilter(result); Index: modules/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/cjk/CJKAnalyzer.java (working copy) @@ -17,47 +17,31 @@ * limitations under the License. */ +import java.io.IOException; +import java.io.Reader; +import java.util.Set; + import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Tokenizer; import org.apache.lucene.analysis.core.StopFilter; -import org.apache.lucene.analysis.util.CharArraySet; import org.apache.lucene.analysis.util.StopwordAnalyzerBase; import org.apache.lucene.util.Version; -import java.io.Reader; -import java.util.Arrays; -import java.util.Set; - /** * An {@link Analyzer} that tokenizes text with {@link CJKTokenizer} and * filters with {@link StopFilter} * */ public final class CJKAnalyzer extends StopwordAnalyzerBase { - //~ Static fields/initializers --------------------------------------------- - /** - * An array containing some common English words that are not usually + * File containing default CJK stopwords. + *
+ * Currently it concains some common English words that are not usually * useful for searching and some double-byte interpunctions. - * @deprecated use {@link #getDefaultStopSet()} instead */ - // TODO make this final in 3.1 - - // this might be revised and merged with StopFilter stop words too - @Deprecated - public final static String[] STOP_WORDS = { - "a", "and", "are", "as", "at", "be", - "but", "by", "for", "if", "in", - "into", "is", "it", "no", "not", - "of", "on", "or", "s", "such", "t", - "that", "the", "their", "then", - "there", "these", "they", "this", - "to", "was", "will", "with", "", - "www" - }; + public final static String DEFAULT_STOPWORD_FILE = "stopwords.txt"; - //~ Instance fields -------------------------------------------------------- - /** * Returns an unmodifiable instance of the default stop-words set. * @return an unmodifiable instance of the default stop-words set. @@ -67,13 +51,19 @@ } private static class DefaultSetHolder { - static final Set> DEFAULT_STOP_SET = CharArraySet - .unmodifiableSet(new CharArraySet(Version.LUCENE_CURRENT, Arrays.asList(STOP_WORDS), - false)); + static final Set> DEFAULT_STOP_SET; + + static { + try { + DEFAULT_STOP_SET = loadStopwordSet(false, CJKAnalyzer.class, DEFAULT_STOPWORD_FILE, "#"); + } catch (IOException ex) { + // default set should always be present as it is part of the + // distribution (JAR) + throw new RuntimeException("Unable to load default stopword set"); + } + } } - //~ Constructors ----------------------------------------------------------- - /** * Builds an analyzer which removes words in {@link #STOP_WORDS}. */ @@ -93,19 +83,6 @@ super(matchVersion, stopwords); } - /** - * Builds an analyzer which removes words in the provided array. - * - * @param stopWords stop word array - * @deprecated use {@link #CJKAnalyzer(Version, Set)} instead - */ - @Deprecated - public CJKAnalyzer(Version matchVersion, String... stopWords) { - super(matchVersion, StopFilter.makeStopSet(matchVersion, stopWords)); - } - - //~ Methods ---------------------------------------------------------------- - @Override protected TokenStreamComponents createComponents(String fieldName, Reader reader) { Index: modules/analysis/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/cz/CzechAnalyzer.java (working copy) @@ -27,6 +27,7 @@ import org.apache.lucene.analysis.standard.StandardTokenizer; import org.apache.lucene.analysis.util.CharArraySet; import org.apache.lucene.analysis.util.ReusableAnalyzerBase; +import org.apache.lucene.analysis.util.StopwordAnalyzerBase; import org.apache.lucene.analysis.util.WordlistLoader; import org.apache.lucene.util.Version; @@ -54,35 +55,7 @@ * LUCENE-1068) * */ -public final class CzechAnalyzer extends ReusableAnalyzerBase { - - /** - * List of typical stopwords. - * @deprecated use {@link #getDefaultStopSet()} instead - */ - // TODO make this private in 3.1 - @Deprecated - public final static String[] CZECH_STOP_WORDS = { - "a","s","k","o","i","u","v","z","dnes","cz","t\u00edmto","bude\u0161","budem", - "byli","jse\u0161","m\u016fj","sv\u00fdm","ta","tomto","tohle","tuto","tyto", - "jej","zda","pro\u010d","m\u00e1te","tato","kam","tohoto","kdo","kte\u0159\u00ed", - "mi","n\u00e1m","tom","tomuto","m\u00edt","nic","proto","kterou","byla", - "toho","proto\u017ee","asi","ho","na\u0161i","napi\u0161te","re","co\u017e","t\u00edm", - "tak\u017ee","sv\u00fdch","jej\u00ed","sv\u00fdmi","jste","aj","tu","tedy","teto", - "bylo","kde","ke","prav\u00e9","ji","nad","nejsou","\u010di","pod","t\u00e9ma", - "mezi","p\u0159es","ty","pak","v\u00e1m","ani","kdy\u017e","v\u0161ak","neg","jsem", - "tento","\u010dl\u00e1nku","\u010dl\u00e1nky","aby","jsme","p\u0159ed","pta","jejich", - "byl","je\u0161t\u011b","a\u017e","bez","tak\u00e9","pouze","prvn\u00ed","va\u0161e","kter\u00e1", - "n\u00e1s","nov\u00fd","tipy","pokud","m\u016f\u017ee","strana","jeho","sv\u00e9","jin\u00e9", - "zpr\u00e1vy","nov\u00e9","nen\u00ed","v\u00e1s","jen","podle","zde","u\u017e","b\u00fdt","v\u00edce", - "bude","ji\u017e","ne\u017e","kter\u00fd","by","kter\u00e9","co","nebo","ten","tak", - "m\u00e1","p\u0159i","od","po","jsou","jak","dal\u0161\u00ed","ale","si","se","ve", - "to","jako","za","zp\u011bt","ze","do","pro","je","na","atd","atp", - "jakmile","p\u0159i\u010dem\u017e","j\u00e1","on","ona","ono","oni","ony","my","vy", - "j\u00ed","ji","m\u011b","mne","jemu","tomu","t\u011bm","t\u011bmu","n\u011bmu","n\u011bmu\u017e", - "jeho\u017e","j\u00ed\u017e","jeliko\u017e","je\u017e","jako\u017e","na\u010de\u017e", - }; - +public final class CzechAnalyzer extends StopwordAnalyzerBase { /** File containing default Czech stopwords. */ public final static String DEFAULT_STOPWORD_FILE = "stopwords.txt"; @@ -112,27 +85,21 @@ } - /** - * Contains the stopwords used with the {@link StopFilter}. - */ - // TODO once loadStopWords is gone those member should be removed too in favor of StopwordAnalyzerBase - private Set> stoptable; - private final Version matchVersion; private final Set> stemExclusionTable; /** * Builds an analyzer with the default stop words ({@link #CZECH_STOP_WORDS}). - * + * * @param matchVersion Lucene version to match See * {@link above} */ public CzechAnalyzer(Version matchVersion) { this(matchVersion, DefaultSetHolder.DEFAULT_SET); } - + /** * Builds an analyzer with the given stop words. - * + * * @param matchVersion Lucene version to match See * {@link above} * @param stopwords a stopword set @@ -140,7 +107,7 @@ public CzechAnalyzer(Version matchVersion, Set> stopwords) { this(matchVersion, stopwords, CharArraySet.EMPTY_SET); } - + /** * Builds an analyzer with the given stop words and a set of work to be * excluded from the {@link CzechStemFilter}. @@ -151,85 +118,11 @@ * @param stemExclusionTable a stemming exclusion set */ public CzechAnalyzer(Version matchVersion, Set> stopwords, Set> stemExclusionTable) { - this.matchVersion = matchVersion; - this.stoptable = CharArraySet.unmodifiableSet(CharArraySet.copy(matchVersion, stopwords)); + super(matchVersion, stopwords); this.stemExclusionTable = CharArraySet.unmodifiableSet(CharArraySet.copy(matchVersion, stemExclusionTable)); } - /** - * Builds an analyzer with the given stop words. - * - * @param matchVersion Lucene version to match See - * {@link above} - * @param stopwords a stopword set - * @deprecated use {@link #CzechAnalyzer(Version, Set)} instead - */ - @Deprecated - public CzechAnalyzer(Version matchVersion, String... stopwords) { - this(matchVersion, StopFilter.makeStopSet( matchVersion, stopwords )); - } - - /** - * Builds an analyzer with the given stop words. - * - * @param matchVersion Lucene version to match See - * {@link above} - * @param stopwords a stopword set - * @deprecated use {@link #CzechAnalyzer(Version, Set)} instead - */ - @Deprecated - public CzechAnalyzer(Version matchVersion, HashSet> stopwords) { - this(matchVersion, (Set>)stopwords); - } - - /** - * Builds an analyzer with the given stop words. - * - * @param matchVersion Lucene version to match See - * {@link above} - * @param stopwords a file containing stopwords - * @deprecated use {@link #CzechAnalyzer(Version, Set)} instead - */ - @Deprecated - public CzechAnalyzer(Version matchVersion, File stopwords ) throws IOException { - this(matchVersion, (Set>)WordlistLoader.getWordSet( stopwords )); - } - - /** - * Loads stopwords hash from resource stream (file, database...). - * @param wordfile File containing the wordlist - * @param encoding Encoding used (win-1250, iso-8859-2, ...), null for default system encoding - * @deprecated use {@link WordlistLoader#getWordSet(Reader, String) } - * and {@link #CzechAnalyzer(Version, Set)} instead - */ - // TODO extend StopwordAnalyzerBase once this method is gone! - @Deprecated - public void loadStopWords( InputStream wordfile, String encoding ) { - setPreviousTokenStream(null); // force a new stopfilter to be created - if ( wordfile == null ) { - stoptable = Collections.emptySet(); - return; - } - try { - // clear any previous table (if present) - stoptable = Collections.emptySet(); - - InputStreamReader isr; - if (encoding == null) - isr = new InputStreamReader(wordfile); - else - isr = new InputStreamReader(wordfile, encoding); - - stoptable = WordlistLoader.getWordSet(isr); - } catch ( IOException e ) { - // clear any previous table (if present) - // TODO: throw IOException - stoptable = Collections.emptySet(); - } - } - - /** * Creates * {@link org.apache.lucene.analysis.util.ReusableAnalyzerBase.TokenStreamComponents} * used to tokenize all the text in the provided {@link Reader}. @@ -244,12 +137,12 @@ * {@link CzechStemFilter}. */ @Override - protected TokenStreamComponents createComponents(String fieldName, + protected ReusableAnalyzerBase.TokenStreamComponents createComponents(String fieldName, Reader reader) { final Tokenizer source = new StandardTokenizer(matchVersion, reader); TokenStream result = new StandardFilter(matchVersion, source); result = new LowerCaseFilter(matchVersion, result); - result = new StopFilter( matchVersion, result, stoptable); + result = new StopFilter( matchVersion, result, stopwords); if (matchVersion.onOrAfter(Version.LUCENE_31)) { if(!this.stemExclusionTable.isEmpty()) result = new KeywordMarkerFilter(result, stemExclusionTable); Index: modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java =================================================================== --- modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java (revision 1040383) +++ modules/analysis/common/src/java/org/apache/lucene/analysis/synonym/SynonymMap.java (working copy) @@ -53,9 +53,9 @@ SynonymMap currMap = this; for (String str : singleMatch) { if (currMap.submap==null) { - // for now hardcode at 2.9, as its what the old code did. + // for now hardcode at 4.0, as its what the old code did. // would be nice to fix, but shouldn't store a version in each submap!!! - currMap.submap = new CharArrayMapfalse if and only if the set should be case sensitive
- * otherwise true.
- * @deprecated use {@link #CharArraySet(Version, int, boolean)} instead
- */
- @Deprecated
- public CharArraySet(int startSize, boolean ignoreCase) {
- this(Version.LUCENE_30, startSize, ignoreCase);
- }
-
- /**
- * Creates a set from a Collection of objects.
- *
- * @param c
- * a collection whose elements to be placed into the set
- * @param ignoreCase
- * false if and only if the set should be case sensitive
- * otherwise true.
- * @deprecated use {@link #CharArraySet(Version, Collection, boolean)} instead
- */
- @Deprecated
- public CharArraySet(Collection> c, boolean ignoreCase) {
- this(Version.LUCENE_30, c.size(), ignoreCase);
- addAll(c);
- }
-
/** Create set from the specified map (internal only), used also by {@link CharArrayMap#keySet()} */
CharArraySet(final CharArrayMap
* Note: If you intend to create a copy of another {@link CharArraySet} where
* the {@link Version} of the source set differs from its copy
@@ -248,68 +198,13 @@
return new CharArraySet(matchVersion, set, false);
}
- /** The Iterator
@@ -177,6 +155,21 @@
/** Used to track if setUp and tearDown are called correctly from subclasses */
private boolean setup;
+ /**
+ * Some tests expect the directory to contain a single segment, and want to do tests on that segment's reader.
+ * This is an utility method to help them.
+ */
+ public static SegmentReader getOnlySegmentReader(IndexReader reader) {
+ if (reader instanceof SegmentReader)
+ return (SegmentReader) reader;
+
+ IndexReader[] subReaders = reader.getSequentialSubReaders();
+ if (subReaders.length != 1)
+ throw new IllegalArgumentException(reader + " has " + subReaders.length + " segments instead of exactly one");
+
+ return (SegmentReader) subReaders[0];
+ }
+
private static class UncaughtExceptionEntry {
public final Thread thread;
public final Throwable exception;
@@ -308,7 +301,7 @@
}
}
- /** @deprecated: until we fix no-fork problems in solr tests */
+ /** @deprecated (4.0) until we fix no-fork problems in solr tests */
@Deprecated
private static List
* The date resolution that shall be used for RangeQueries can be set
@@ -91,10 +88,9 @@
* resolutions take, if set, precedence over the default date resolution.
*
- * If you use neither {@link DateField} nor {@link DateTools} in your
- * index, you can create your own
+ * If you don't use {@link DateTools} in your index, you can create your own
* query parser that inherits QueryParser and overwrites
- * {@link #getRangeQuery(String, String, String, boolean)} to
+ * {@link #getRangeQuery(String, String, String, boolean, boolean)} to
* use a different method for date conversion.
* NOTE: You must specify the required {@link Version}
* compatibility when creating QueryParser:
* nextCharArray for more efficient access.
- * @deprecated Use the standard iterator, which returns {@code char[]} instances.
+ /**
+ * Returns an {@link Iterator} for {@code char[]} instances in this set.
*/
- @Deprecated
- public class CharArraySetIterator implements Iterator
- *
- */
@Override @SuppressWarnings("unchecked")
public Iterator
- *
Index: lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj
===================================================================
--- lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj (revision 1040383)
+++ lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj (working copy)
@@ -42,7 +42,6 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
-import org.apache.lucene.document.DateField;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
@@ -101,10 +100,8 @@
* date:[6/1/2005 TO 6/4/2005] produces a range query that searches
* for "date" fields between 2005-06-01 and 2005-06-04. Note that the format
* of the accepted input depends on {@link #setLocale(Locale) the locale}.
- * By default a date is converted into a search term using the deprecated
- * {@link DateField} for compatibility reasons.
- * To use the new {@link DateTools} to convert dates, a
- * {@link org.apache.lucene.document.DateTools.Resolution} has to be set.
+ * A {@link org.apache.lucene.document.DateTools.Resolution} has to be set,
+ * if you want to use {@link DateTools} for date conversion.
*
* The date resolution that shall be used for RangeQueries can be set @@ -115,10 +112,9 @@ * resolutions take, if set, precedence over the default date resolution. *
*- * If you use neither {@link DateField} nor {@link DateTools} in your - * index, you can create your own + * If you don't use {@link DateTools} in your index, you can create your own * query parser that inherits QueryParser and overwrites - * {@link #getRangeQuery(String, String, String, boolean)} to + * {@link #getRangeQuery(String, String, String, boolean, boolean)} to * use a different method for date conversion. *
* @@ -132,8 +128,6 @@ *NOTE: You must specify the required {@link Version} * compatibility when creating QueryParser: *
- * Default: false.
+ * Default: true.
*/
public void setEnablePositionIncrements(boolean enable) {
this.enablePositionIncrements = enable;
@@ -489,15 +465,6 @@
}
/**
- * @deprecated Use {@link #getFieldQuery(String,String,boolean)} instead.
- */
- @Deprecated
- protected Query getFieldQuery(String field, String queryText) throws ParseException {
- // treat the text as if it was quoted, to drive phrase logic with old versions.
- return getFieldQuery(field, queryText, true);
- }
-
- /**
* @exception org.apache.lucene.queryParser.ParseException throw in overridden method to disallow
*/
protected Query getFieldQuery(String field, String queryText, boolean quoted) throws ParseException {
@@ -684,7 +651,7 @@
*/
protected Query getFieldQuery(String field, String queryText, int slop)
throws ParseException {
- Query query = hasNewAPI ? getFieldQuery(field, queryText, true) : getFieldQuery(field, queryText);
+ Query query = getFieldQuery(field, queryText, true);
if (query instanceof PhraseQuery) {
((PhraseQuery) query).setSlop(slop);
@@ -696,11 +663,6 @@
return query;
}
-
- @Deprecated
- protected final Query getRangeQuery(String field, String part1, String part2, boolean inclusive) throws MethodRemovedUseAnother {return null;}
-
-
/**
*
* @exception org.apache.lucene.queryParser.ParseException
@@ -722,15 +684,7 @@
DateTools.Resolution resolution = getDateResolution(field);
try {
- Date d1 = df.parse(part1);
- if (resolution == null) {
- // no default or field specific date resolution has been set,
- // use deprecated DateField to maintain compatibility with
- // pre-1.9 Lucene versions.
- part1 = DateField.dateToString(d1);
- } else {
- part1 = DateTools.dateToString(d1, resolution);
- }
+ part1 = DateTools.dateToString(df.parse(part1), resolution);
} catch (Exception e) { }
try {
@@ -747,14 +701,7 @@
cal.set(Calendar.MILLISECOND, 999);
d2 = cal.getTime();
}
- if (resolution == null) {
- // no default or field specific date resolution has been set,
- // use deprecated DateField to maintain compatibility with
- // pre-1.9 Lucene versions.
- part2 = DateField.dateToString(d2);
- } else {
- part2 = DateTools.dateToString(d2, resolution);
- }
+ part2 = DateTools.dateToString(d2, resolution);
} catch (Exception e) { }
return newRangeQuery(field, part1, part2, startInclusive, endInclusive);
@@ -838,10 +785,6 @@
return new FuzzyQuery(term,minimumSimilarity,prefixLength);
}
- @Deprecated
- protected final Query newRangeQuery(String field, String part1, String part2, boolean inclusive) throws MethodRemovedUseAnother {return null;}
-
-
/**
* Builds a new TermRangeQuery instance
* @param field Field
@@ -1064,7 +1007,7 @@
}
q = getFuzzyQuery(qfield, termImage, fms);
} else {
- q = hasNewAPI ? getFieldQuery(qfield, termImage, false) : getFieldQuery(qfield, termImage);
+ q = getFieldQuery(qfield, termImage, false);
}
return q;
}
Index: lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java
===================================================================
--- lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/queryParser/QueryParserTokenManager.java (working copy)
@@ -16,7 +16,6 @@
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.TermToBytesRefAttribute;
-import org.apache.lucene.document.DateField;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.BooleanClause;
Index: lucene/src/java/org/apache/lucene/analysis/CharTokenizer.java
===================================================================
--- lucene/src/java/org/apache/lucene/analysis/CharTokenizer.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/analysis/CharTokenizer.java (working copy)
@@ -25,7 +25,6 @@
import org.apache.lucene.util.AttributeSource;
import org.apache.lucene.util.CharacterUtils;
import org.apache.lucene.util.Version;
-import org.apache.lucene.util.VirtualMethod;
import org.apache.lucene.util.CharacterUtils.CharacterBuffer;
/**
@@ -78,8 +77,6 @@
public CharTokenizer(Version matchVersion, Reader input) {
super(input);
charUtils = CharacterUtils.getInstance(matchVersion);
- useOldAPI = useOldAPI(matchVersion);
-
}
/**
@@ -96,7 +93,6 @@
Reader input) {
super(source, input);
charUtils = CharacterUtils.getInstance(matchVersion);
- useOldAPI = useOldAPI(matchVersion);
}
/**
@@ -113,147 +109,30 @@
Reader input) {
super(factory, input);
charUtils = CharacterUtils.getInstance(matchVersion);
- useOldAPI = useOldAPI(matchVersion);
}
- /**
- * Creates a new {@link CharTokenizer} instance
- * @param input the input to split up into tokens
- * @deprecated use {@link #CharTokenizer(Version, Reader)} instead. This will be
- * removed in Lucene 4.0.
- */
- @Deprecated
- public CharTokenizer(Reader input) {
- this(Version.LUCENE_30, input);
- }
-
- /**
- * Creates a new {@link CharTokenizer} instance
- * @param input the input to split up into tokens
- * @param source the attribute source to use for this {@link Tokenizer}
- * @deprecated use {@link #CharTokenizer(Version, AttributeSource, Reader)} instead. This will be
- * removed in Lucene 4.0.
- */
- @Deprecated
- public CharTokenizer(AttributeSource source, Reader input) {
- this(Version.LUCENE_30, source, input);
- }
-
- /**
- * Creates a new {@link CharTokenizer} instance
- * @param input the input to split up into tokens
- * @param factory the attribute factory to use for this {@link Tokenizer}
- * @deprecated use {@link #CharTokenizer(Version, AttributeSource.AttributeFactory, Reader)} instead. This will be
- * removed in Lucene 4.0.
- */
- @Deprecated
- public CharTokenizer(AttributeFactory factory, Reader input) {
- this(Version.LUCENE_30, factory, input);
- }
-
private int offset = 0, bufferIndex = 0, dataLen = 0, finalOffset = 0;
private static final int MAX_WORD_LEN = 255;
private static final int IO_BUFFER_SIZE = 4096;
- private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);;
+ private final CharTermAttribute termAtt = addAttribute(CharTermAttribute.class);
private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
private final CharacterUtils charUtils;
private final CharacterBuffer ioBuffer = CharacterUtils.newCharacterBuffer(IO_BUFFER_SIZE);
/**
- * @deprecated this will be removed in lucene 4.0
- */
- @Deprecated
- private final boolean useOldAPI;
-
- /**
- * @deprecated this will be removed in lucene 4.0
- */
- @Deprecated
- private static final VirtualMethod
- * Note: This method cannot handle supplementary characters. To support all Unicode characters, including
- * supplementary characters, use the {@link #isTokenChar(int)} method.
- *
- * Note: This method cannot handle supplementary characters. To support all Unicode characters, including
- * supplementary characters, use the {@link #normalize(int)} method.
- *
- * As of Lucene 3.1 the char based API ({@link #isTokenChar(char)} and
- * {@link #normalize(char)}) has been depreciated in favor of a Unicode 4.0
- * compatible int based API to support codepoints instead of UTF-16 code
- * units. Subclasses of {@link CharTokenizer} must not override the char based
- * methods if a {@link Version} >= 3.1 is passed to the constructor.
- *
- *
- * NOTE: This method will be marked abstract in Lucene 4.0.
- *
- * As of Lucene 3.1 the char based API ({@link #isTokenChar(char)} and
- * {@link #normalize(char)}) has been depreciated in favor of a Unicode 4.0
- * compatible int based API to support codepoints instead of UTF-16 code
- * units. Subclasses of {@link CharTokenizer} must not override the char based
- * methods if a {@link Version} >= 3.1 is passed to the constructor.
- *
- *
- * NOTE: This method will be marked abstract in Lucene 4.0.
- * false are
- * used to define token boundaries and are not included in tokens.
- *
null if no parser was specified. Sorting is using the default parser then.
* @return An instance of a {@link FieldCache} parser, or null.
- * @deprecated use getEntryCreator()
+ * @deprecated (4.0) use getEntryCreator()
*/
@Deprecated
public FieldCache.Parser getParser() {
Index: lucene/src/java/org/apache/lucene/index/Term.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/Term.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/index/Term.java (working copy)
@@ -168,7 +168,7 @@
BytesRef.getUTF8SortedAsUTF16Comparator();
/**
- * @deprecated For internal backwards compatibility use only
+ * @deprecated (4.0) For internal backwards compatibility use only
* @lucene.internal
*/
@Deprecated
Index: lucene/src/java/org/apache/lucene/index/SegmentReader.java
===================================================================
--- lucene/src/java/org/apache/lucene/index/SegmentReader.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/index/SegmentReader.java (working copy)
@@ -1240,34 +1240,7 @@
public final Object getCoreCacheKey() {
return core;
}
-
- /**
- * Lotsa tests did hacks like:Get the current setting of whether newly flushed - * segments will use the compound file format. Note that - * this just returns the value previously set with - * setUseCompoundFile(boolean), or the default value - * (true). You cannot use this to query the status of - * previously flushed segments.
- * - *Note that this method is a convenience method: it - * just calls mergePolicy.getUseCompoundFile as long as - * mergePolicy is an instance of {@link LogMergePolicy}. - * Otherwise an IllegalArgumentException is thrown.
- * - * @see #setUseCompoundFile(boolean) - * @deprecated use {@link LogMergePolicy#getUseCompoundDocStore()} and - * {@link LogMergePolicy#getUseCompoundFile()} directly. - */ - @Deprecated - public boolean getUseCompoundFile() { - return getLogMergePolicy().getUseCompoundFile(); - } - - /** - *- * Setting to turn on usage of a compound file. When on, multiple files for - * each segment are merged into a single file when a new segment is flushed. - *
- * - *- * Note that this method is a convenience method: it just calls - * mergePolicy.setUseCompoundFile as long as mergePolicy is an instance of - * {@link LogMergePolicy}. Otherwise an IllegalArgumentException is thrown. - *
- * - * @deprecated use {@link LogMergePolicy#setUseCompoundDocStore(boolean)} and - * {@link LogMergePolicy#setUseCompoundFile(boolean)} directly. - * Note that this method set the given value on both, therefore - * you should consider doing the same. - */ - @Deprecated - public void setUseCompoundFile(boolean value) { - getLogMergePolicy().setUseCompoundFile(value); - getLogMergePolicy().setUseCompoundDocStore(value); - } - - /** Expert: Set the Similarity implementation used by this IndexWriter. - * - * @see Similarity#setDefault(Similarity) - * @deprecated use {@link IndexWriterConfig#setSimilarity(Similarity)} instead - */ - @Deprecated - public void setSimilarity(Similarity similarity) { - ensureOpen(); - this.similarity = similarity; - docWriter.setSimilarity(similarity); - // Required so config.getSimilarity returns the right value. But this will - // go away together with the method in 4.0. - config.setSimilarity(similarity); - } - - /** Expert: Return the Similarity implementation used by this IndexWriter. - * - *This defaults to the current value of {@link Similarity#getDefault()}.
- * @deprecated use {@link IndexWriterConfig#getSimilarity()} instead
- */
- @Deprecated
- public Similarity getSimilarity() {
- ensureOpen();
- return similarity;
- }
-
- /** Expert: Set the interval between indexed terms. Large values cause less
- * memory to be used by IndexReader, but slow random-access to terms. Small
- * values cause more memory to be used by an IndexReader, and speed
- * random-access to terms.
- *
- * This parameter determines the amount of computation required per query
- * term, regardless of the number of documents that contain that term. In
- * particular, it is the maximum number of other terms that must be
- * scanned before a term is located and its frequency and position information
- * may be processed. In a large index with user-entered query terms, query
- * processing time is likely to be dominated not by term lookup but rather
- * by the processing of frequency and positional data. In a small index
- * or when many uncommon query terms are generated (e.g., by wildcard
- * queries) term lookup may become a dominant cost.
- *
- * In particular, numUniqueTerms/interval terms are read into
- * memory by an IndexReader, and, on average, interval/2 terms
- * must be scanned for each random term access.
- *
- * @see #DEFAULT_TERM_INDEX_INTERVAL
- * @deprecated use {@link IndexWriterConfig#setTermIndexInterval(int)}
- */
- @Deprecated
- public void setTermIndexInterval(int interval) {
- ensureOpen();
- this.termIndexInterval = interval;
- // Required so config.getTermIndexInterval returns the right value. But this
- // will go away together with the method in 4.0.
- config.setTermIndexInterval(interval);
- }
-
- /** Expert: Return the interval between indexed terms.
- *
- * @see #setTermIndexInterval(int)
- * @deprecated use {@link IndexWriterConfig#getTermIndexInterval()}
- */
- @Deprecated
- public int getTermIndexInterval() {
- // We pass false because this method is called by SegmentMerger while we are in the process of closing
- ensureOpen(false);
- return termIndexInterval;
- }
-
- /**
- * Constructs an IndexWriter for the index in d.
- * Text will be analyzed with a. If create
- * is true, then a new, empty index will be created in
- * d, replacing the index already there, if any.
- *
- * @param d the index directory
- * @param a the analyzer to use
- * @param create true to create the index or overwrite
- * the existing one; false to append to the existing
- * index
- * @param mfl Maximum field length in number of terms/tokens: LIMITED, UNLIMITED, or user-specified
- * via the MaxFieldLength constructor.
- * @throws CorruptIndexException if the index is corrupt
- * @throws LockObtainFailedException if another writer
- * has this index open (write.lock could not
- * be obtained)
- * @throws IOException if the directory cannot be read/written to, or
- * if it does not exist and create is
- * false or if there is any other low-level
- * IO error
- * @deprecated use {@link #IndexWriter(Directory, IndexWriterConfig)} instead
- */
- @Deprecated
- public IndexWriter(Directory d, Analyzer a, boolean create, MaxFieldLength mfl)
- throws CorruptIndexException, LockObtainFailedException, IOException {
- this(d, new IndexWriterConfig(Version.LUCENE_31, a).setOpenMode(
- create ? OpenMode.CREATE : OpenMode.APPEND).setMaxFieldLength(
- mfl.getLimit()));
- }
-
- /**
- * Constructs an IndexWriter for the index in
- * d, first creating it if it does not
- * already exist. Text will be analyzed with
- * a.
- *
- * @param d the index directory
- * @param a the analyzer to use
- * @param mfl Maximum field length in number of terms/tokens: LIMITED, UNLIMITED, or user-specified
- * via the MaxFieldLength constructor.
- * @throws CorruptIndexException if the index is corrupt
- * @throws LockObtainFailedException if another writer
- * has this index open (write.lock could not
- * be obtained)
- * @throws IOException if the directory cannot be
- * read/written to or if there is any other low-level
- * IO error
- * @deprecated use {@link #IndexWriter(Directory, IndexWriterConfig)} instead
- */
- @Deprecated
- public IndexWriter(Directory d, Analyzer a, MaxFieldLength mfl)
- throws CorruptIndexException, LockObtainFailedException, IOException {
- this(d, new IndexWriterConfig(Version.LUCENE_31, a)
- .setMaxFieldLength(mfl.getLimit()));
- }
-
- /**
- * Expert: constructs an IndexWriter with a custom {@link
- * IndexDeletionPolicy}, for the index in d,
- * first creating it if it does not already exist. Text
- * will be analyzed with a.
- *
- * @param d the index directory
- * @param a the analyzer to use
- * @param deletionPolicy see above
- * @param mfl whether or not to limit field lengths
- * @throws CorruptIndexException if the index is corrupt
- * @throws LockObtainFailedException if another writer
- * has this index open (write.lock could not
- * be obtained)
- * @throws IOException if the directory cannot be
- * read/written to or if there is any other low-level
- * IO error
- * @deprecated use {@link #IndexWriter(Directory, IndexWriterConfig)} instead
- */
- @Deprecated
- public IndexWriter(Directory d, Analyzer a, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl)
- throws CorruptIndexException, LockObtainFailedException, IOException {
- this(d, new IndexWriterConfig(Version.LUCENE_31, a).setMaxFieldLength(
- mfl.getLimit()).setIndexDeletionPolicy(deletionPolicy));
- }
-
- /**
- * Expert: constructs an IndexWriter with a custom {@link
- * IndexDeletionPolicy}, for the index in d.
- * Text will be analyzed with a. If
- * create is true, then a new, empty index
- * will be created in d, replacing the index
- * already there, if any.
- *
- * @param d the index directory
- * @param a the analyzer to use
- * @param create true to create the index or overwrite
- * the existing one; false to append to the existing
- * index
- * @param deletionPolicy see above
- * @param mfl {@link org.apache.lucene.index.IndexWriter.MaxFieldLength}, whether or not to limit field lengths. Value is in number of terms/tokens
- * @throws CorruptIndexException if the index is corrupt
- * @throws LockObtainFailedException if another writer
- * has this index open (write.lock could not
- * be obtained)
- * @throws IOException if the directory cannot be read/written to, or
- * if it does not exist and create is
- * false or if there is any other low-level
- * IO error
- * @deprecated use {@link #IndexWriter(Directory, IndexWriterConfig)} instead
- */
- @Deprecated
- public IndexWriter(Directory d, Analyzer a, boolean create, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl)
- throws CorruptIndexException, LockObtainFailedException, IOException {
- this(d, new IndexWriterConfig(Version.LUCENE_31, a).setOpenMode(
- create ? OpenMode.CREATE : OpenMode.APPEND).setMaxFieldLength(
- mfl.getLimit()).setIndexDeletionPolicy(deletionPolicy));
- }
-
- /**
- * Expert: constructs an IndexWriter on specific commit
- * point, with a custom {@link IndexDeletionPolicy}, for
- * the index in d. Text will be analyzed
- * with a.
- *
- *
This is only meaningful if you've used a {@link - * IndexDeletionPolicy} in that past that keeps more than - * just the last commit. - * - *
This operation is similar to {@link #rollback()},
- * except that method can only rollback what's been done
- * with the current instance of IndexWriter since its last
- * commit, whereas this method can rollback to an
- * arbitrary commit point from the past, assuming the
- * {@link IndexDeletionPolicy} has preserved past
- * commits.
- *
- * @param d the index directory
- * @param a the analyzer to use
- * @param deletionPolicy see above
- * @param mfl whether or not to limit field lengths, value is in number of terms/tokens. See {@link org.apache.lucene.index.IndexWriter.MaxFieldLength}.
- * @param commit which commit to open
- * @throws CorruptIndexException if the index is corrupt
- * @throws LockObtainFailedException if another writer
- * has this index open (write.lock could not
- * be obtained)
- * @throws IOException if the directory cannot be read/written to, or
- * if it does not exist and create is
- * false or if there is any other low-level
- * IO error
- * @deprecated use {@link #IndexWriter(Directory, IndexWriterConfig)} instead
- */
- @Deprecated
- public IndexWriter(Directory d, Analyzer a, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl, IndexCommit commit)
- throws CorruptIndexException, LockObtainFailedException, IOException {
- this(d, new IndexWriterConfig(Version.LUCENE_31, a)
- .setOpenMode(OpenMode.APPEND).setMaxFieldLength(mfl.getLimit())
- .setIndexDeletionPolicy(deletionPolicy).setIndexCommit(commit));
- }
-
CodecProvider codecs;
/**
@@ -1038,8 +706,6 @@
setMessageID(defaultInfoStream);
maxFieldLength = conf.getMaxFieldLength();
termIndexInterval = conf.getTermIndexInterval();
- writeLockTimeout = conf.getWriteLockTimeout();
- similarity = conf.getSimilarity();
mergePolicy = conf.getMergePolicy();
mergePolicy.setIndexWriter(this);
mergeScheduler = conf.getMergeScheduler();
@@ -1061,7 +727,7 @@
writeLock = directory.makeLock(WRITE_LOCK_NAME);
- if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
+ if (!writeLock.obtain(conf.getWriteLockTimeout())) // obtain write lock
throw new LockObtainFailedException("Index locked for write: " + writeLock);
boolean success = false;
@@ -1177,202 +843,12 @@
}
/**
- * Expert: set the merge policy used by this writer.
- *
- * @deprecated use {@link IndexWriterConfig#setMergePolicy(MergePolicy)} instead.
- */
- @Deprecated
- public void setMergePolicy(MergePolicy mp) {
- ensureOpen();
- if (mp == null)
- throw new NullPointerException("MergePolicy must be non-null");
-
- if (mergePolicy != mp)
- mergePolicy.close();
- mergePolicy = mp;
- mergePolicy.setIndexWriter(this);
- pushMaxBufferedDocs();
- if (infoStream != null)
- message("setMergePolicy " + mp);
- // Required so config.getMergePolicy returns the right value. But this will
- // go away together with the method in 4.0.
- config.setMergePolicy(mp);
- }
-
- /**
- * Expert: returns the current MergePolicy in use by this writer.
- * @see #setMergePolicy
- *
- * @deprecated use {@link IndexWriterConfig#getMergePolicy()} instead
- */
- @Deprecated
- public MergePolicy getMergePolicy() {
- ensureOpen();
- return mergePolicy;
- }
-
- /**
- * Expert: set the merge scheduler used by this writer.
- * @deprecated use {@link IndexWriterConfig#setMergeScheduler(MergeScheduler)} instead
- */
- @Deprecated
- synchronized public void setMergeScheduler(MergeScheduler mergeScheduler) throws CorruptIndexException, IOException {
- ensureOpen();
- if (mergeScheduler == null)
- throw new NullPointerException("MergeScheduler must be non-null");
-
- if (this.mergeScheduler != mergeScheduler) {
- finishMerges(true);
- this.mergeScheduler.close();
- }
- this.mergeScheduler = mergeScheduler;
- if (infoStream != null)
- message("setMergeScheduler " + mergeScheduler);
- // Required so config.getMergeScheduler returns the right value. But this will
- // go away together with the method in 4.0.
- config.setMergeScheduler(mergeScheduler);
- }
-
- /**
- * Expert: returns the current MergeScheduler in use by this
- * writer.
- * @see #setMergeScheduler(MergeScheduler)
- * @deprecated use {@link IndexWriterConfig#getMergeScheduler()} instead
- */
- @Deprecated
- public MergeScheduler getMergeScheduler() {
- ensureOpen();
- return mergeScheduler;
- }
-
- /**
Determines the largest segment (measured by - * document count) that may be merged with other segments. - * Small values (e.g., less than 10,000) are best for - * interactive indexing, as this limits the length of - * pauses while indexing to a few seconds. Larger values - * are best for batched indexing and speedier - * searches.
- * - *The default value is {@link Integer#MAX_VALUE}.
- * - *Note that this method is a convenience method: it - * just calls mergePolicy.setMaxMergeDocs as long as - * mergePolicy is an instance of {@link LogMergePolicy}. - * Otherwise an IllegalArgumentException is thrown.
- * - *The default merge policy ({@link - * LogByteSizeMergePolicy}) also allows you to set this - * limit by net size (in MB) of the segment, using {@link - * LogByteSizeMergePolicy#setMaxMergeMB}.
- * @deprecated use {@link LogMergePolicy#setMaxMergeDocs(int)} directly. - */ - @Deprecated - public void setMaxMergeDocs(int maxMergeDocs) { - getLogMergePolicy().setMaxMergeDocs(maxMergeDocs); - } - - /** - *Returns the largest segment (measured by document - * count) that may be merged with other segments.
- * - *Note that this method is a convenience method: it - * just calls mergePolicy.getMaxMergeDocs as long as - * mergePolicy is an instance of {@link LogMergePolicy}. - * Otherwise an IllegalArgumentException is thrown.
- * - * @see #setMaxMergeDocs - * @deprecated use {@link LogMergePolicy#getMaxMergeDocs()} directly. - */ - @Deprecated - public int getMaxMergeDocs() { - return getLogMergePolicy().getMaxMergeDocs(); - } - - /** - * The maximum number of terms that will be indexed for a single field in a - * document. This limits the amount of memory required for indexing, so that - * collections with very large files will not crash the indexing process by - * running out of memory. This setting refers to the number of running terms, - * not to the number of different terms. - * Note: this silently truncates large documents, excluding from the - * index all terms that occur further in the document. If you know your source - * documents are large, be sure to set this value high enough to accomodate - * the expected size. If you set it to Integer.MAX_VALUE, then the only limit - * is your memory, but you should anticipate an OutOfMemoryError. - * By default, no more than {@link #DEFAULT_MAX_FIELD_LENGTH} terms - * will be indexed for a field. - * @deprecated use {@link IndexWriterConfig#setMaxFieldLength(int)} instead - */ - @Deprecated - public void setMaxFieldLength(int maxFieldLength) { - ensureOpen(); - this.maxFieldLength = maxFieldLength; - docWriter.setMaxFieldLength(maxFieldLength); - if (infoStream != null) - message("setMaxFieldLength " + maxFieldLength); - // Required so config.getMaxFieldLength returns the right value. But this - // will go away together with the method in 4.0. - config.setMaxFieldLength(maxFieldLength); - } - - /** - * Returns the maximum number of terms that will be - * indexed for a single field in a document. - * @see #setMaxFieldLength - * @deprecated use {@link IndexWriterConfig#getMaxFieldLength()} instead - */ - @Deprecated - public int getMaxFieldLength() { - ensureOpen(); - return maxFieldLength; - } - - /** Determines the minimal number of documents required - * before the buffered in-memory documents are flushed as - * a new Segment. Large values generally gives faster - * indexing. - * - *When this is set, the writer will flush every - * maxBufferedDocs added documents. Pass in {@link - * #DISABLE_AUTO_FLUSH} to prevent triggering a flush due - * to number of buffered documents. Note that if flushing - * by RAM usage is also enabled, then the flush will be - * triggered by whichever comes first.
- * - *Disabled by default (writer flushes by RAM usage).
- * - * @throws IllegalArgumentException if maxBufferedDocs is - * enabled but smaller than 2, or it disables maxBufferedDocs - * when ramBufferSize is already disabled - * @see #setRAMBufferSizeMB - * @deprecated use {@link IndexWriterConfig#setMaxBufferedDocs(int)} instead. - */ - @Deprecated - public void setMaxBufferedDocs(int maxBufferedDocs) { - ensureOpen(); - if (maxBufferedDocs != DISABLE_AUTO_FLUSH && maxBufferedDocs < 2) - throw new IllegalArgumentException( - "maxBufferedDocs must at least be 2 when enabled"); - if (maxBufferedDocs == DISABLE_AUTO_FLUSH - && getRAMBufferSizeMB() == DISABLE_AUTO_FLUSH) - throw new IllegalArgumentException( - "at least one of ramBufferSize and maxBufferedDocs must be enabled"); - docWriter.setMaxBufferedDocs(maxBufferedDocs); - pushMaxBufferedDocs(); - if (infoStream != null) - message("setMaxBufferedDocs " + maxBufferedDocs); - // Required so config.getMaxBufferedDocs returns the right value. But this - // will go away together with the method in 4.0. - config.setMaxBufferedDocs(maxBufferedDocs); - } - - /** * If we are flushing by doc count (not by RAM usage), and * using LogDocMergePolicy then push maxBufferedDocs down * as its minMergeDocs, to keep backwards compatibility. */ private void pushMaxBufferedDocs() { - if (docWriter.getMaxBufferedDocs() != DISABLE_AUTO_FLUSH) { + if (docWriter.getMaxBufferedDocs() != IndexWriterConfig.DISABLE_AUTO_FLUSH) { final MergePolicy mp = mergePolicy; if (mp instanceof LogDocMergePolicy) { LogDocMergePolicy lmp = (LogDocMergePolicy) mp; @@ -1386,164 +862,6 @@ } } - /** - * Returns the number of buffered added documents that will - * trigger a flush if enabled. - * @see #setMaxBufferedDocs - * @deprecated use {@link IndexWriterConfig#getMaxBufferedDocs()} instead. - */ - @Deprecated - public int getMaxBufferedDocs() { - ensureOpen(); - return docWriter.getMaxBufferedDocs(); - } - - /** Determines the amount of RAM that may be used for - * buffering added documents and deletions before they are - * flushed to the Directory. Generally for faster - * indexing performance it's best to flush by RAM usage - * instead of document count and use as large a RAM buffer - * as you can. - * - *When this is set, the writer will flush whenever - * buffered documents and deletions use this much RAM. - * Pass in {@link #DISABLE_AUTO_FLUSH} to prevent - * triggering a flush due to RAM usage. Note that if - * flushing by document count is also enabled, then the - * flush will be triggered by whichever comes first.
- * - *NOTE: the account of RAM usage for pending - * deletions is only approximate. Specifically, if you - * delete by Query, Lucene currently has no way to measure - * the RAM usage if individual Queries so the accounting - * will under-estimate and you should compensate by either - * calling commit() periodically yourself, or by using - * {@link #setMaxBufferedDeleteTerms} to flush by count - * instead of RAM usage (each buffered delete Query counts - * as one). - * - *
NOTE: because IndexWriter uses
- * ints when managing its internal storage,
- * the absolute maximum value for this setting is somewhat
- * less than 2048 MB. The precise limit depends on
- * various factors, such as how large your documents are,
- * how many fields have norms, etc., so it's best to set
- * this value comfortably under 2048.
The default value is {@link #DEFAULT_RAM_BUFFER_SIZE_MB}.
- * - * @throws IllegalArgumentException if ramBufferSize is - * enabled but non-positive, or it disables ramBufferSize - * when maxBufferedDocs is already disabled - * @deprecated use {@link IndexWriterConfig#setRAMBufferSizeMB(double)} instead. - */ - @Deprecated - public void setRAMBufferSizeMB(double mb) { - if (mb > 2048.0) { - throw new IllegalArgumentException("ramBufferSize " + mb + " is too large; should be comfortably less than 2048"); - } - if (mb != DISABLE_AUTO_FLUSH && mb <= 0.0) - throw new IllegalArgumentException( - "ramBufferSize should be > 0.0 MB when enabled"); - if (mb == DISABLE_AUTO_FLUSH && getMaxBufferedDocs() == DISABLE_AUTO_FLUSH) - throw new IllegalArgumentException( - "at least one of ramBufferSize and maxBufferedDocs must be enabled"); - docWriter.setRAMBufferSizeMB(mb); - if (infoStream != null) - message("setRAMBufferSizeMB " + mb); - // Required so config.getRAMBufferSizeMB returns the right value. But this - // will go away together with the method in 4.0. - config.setRAMBufferSizeMB(mb); - } - - /** - * Returns the value set by {@link #setRAMBufferSizeMB} if enabled. - * @deprecated use {@link IndexWriterConfig#getRAMBufferSizeMB()} instead. - */ - @Deprecated - public double getRAMBufferSizeMB() { - return docWriter.getRAMBufferSizeMB(); - } - - /** - *Determines the minimal number of delete terms required before the buffered - * in-memory delete terms are applied and flushed. If there are documents - * buffered in memory at the time, they are merged and a new segment is - * created.
- - *Disabled by default (writer flushes by RAM usage).
- * - * @throws IllegalArgumentException if maxBufferedDeleteTerms - * is enabled but smaller than 1 - * @see #setRAMBufferSizeMB - * @deprecated use {@link IndexWriterConfig#setMaxBufferedDeleteTerms(int)} instead. - */ - @Deprecated - public void setMaxBufferedDeleteTerms(int maxBufferedDeleteTerms) { - ensureOpen(); - if (maxBufferedDeleteTerms != DISABLE_AUTO_FLUSH - && maxBufferedDeleteTerms < 1) - throw new IllegalArgumentException( - "maxBufferedDeleteTerms must at least be 1 when enabled"); - docWriter.setMaxBufferedDeleteTerms(maxBufferedDeleteTerms); - if (infoStream != null) - message("setMaxBufferedDeleteTerms " + maxBufferedDeleteTerms); - // Required so config.getMaxBufferedDeleteTerms returns the right value. But - // this will go away together with the method in 4.0. - config.setMaxBufferedDeleteTerms(maxBufferedDeleteTerms); - } - - /** - * Returns the number of buffered deleted terms that will - * trigger a flush if enabled. - * @see #setMaxBufferedDeleteTerms - * @deprecated use {@link IndexWriterConfig#getMaxBufferedDeleteTerms()} instead - */ - @Deprecated - public int getMaxBufferedDeleteTerms() { - ensureOpen(); - return docWriter.getMaxBufferedDeleteTerms(); - } - - /** Determines how often segment indices are merged by addDocument(). With - * smaller values, less RAM is used while indexing, and searches on - * unoptimized indices are faster, but indexing speed is slower. With larger - * values, more RAM is used during indexing, and while searches on unoptimized - * indices are slower, indexing is faster. Thus larger values (> 10) are best - * for batch index creation, and smaller values (< 10) for indices that are - * interactively maintained. - * - *Note that this method is a convenience method: it - * just calls mergePolicy.setMergeFactor as long as - * mergePolicy is an instance of {@link LogMergePolicy}. - * Otherwise an IllegalArgumentException is thrown.
- * - *This must never be less than 2. The default value is 10. - * @deprecated use {@link LogMergePolicy#setMergeFactor(int)} directly. - */ - @Deprecated - public void setMergeFactor(int mergeFactor) { - getLogMergePolicy().setMergeFactor(mergeFactor); - } - - /** - *
Returns the number of segments that are merged at - * once and also controls the total number of segments - * allowed to accumulate in the index.
- * - *Note that this method is a convenience method: it - * just calls mergePolicy.getMergeFactor as long as - * mergePolicy is an instance of {@link LogMergePolicy}. - * Otherwise an IllegalArgumentException is thrown.
- * - * @see #setMergeFactor - * @deprecated use {@link LogMergePolicy#getMergeFactor()} directly. - */ - @Deprecated - public int getMergeFactor() { - return getLogMergePolicy().getMergeFactor(); - } - /** If non-null, this will be the default infoStream used * by a newly instantiated IndexWriter. * @see #setInfoStream @@ -1596,52 +914,6 @@ } /** - * Sets the maximum time to wait for a write lock (in milliseconds) for this instance of IndexWriter. @see - * @see #setDefaultWriteLockTimeout to change the default value for all instances of IndexWriter. - * @deprecated use {@link IndexWriterConfig#setWriteLockTimeout(long)} instead - */ - @Deprecated - public void setWriteLockTimeout(long writeLockTimeout) { - ensureOpen(); - this.writeLockTimeout = writeLockTimeout; - // Required so config.getWriteLockTimeout returns the right value. But this - // will go away together with the method in 4.0. - config.setWriteLockTimeout(writeLockTimeout); - } - - /** - * Returns allowed timeout when acquiring the write lock. - * @see #setWriteLockTimeout - * @deprecated use {@link IndexWriterConfig#getWriteLockTimeout()} - */ - @Deprecated - public long getWriteLockTimeout() { - ensureOpen(); - return writeLockTimeout; - } - - /** - * Sets the default (for any instance of IndexWriter) maximum time to wait for a write lock (in - * milliseconds). - * @deprecated use {@link IndexWriterConfig#setDefaultWriteLockTimeout(long)} instead - */ - @Deprecated - public static void setDefaultWriteLockTimeout(long writeLockTimeout) { - IndexWriterConfig.setDefaultWriteLockTimeout(writeLockTimeout); - } - - /** - * Returns default write lock timeout for newly - * instantiated IndexWriters. - * @see #setDefaultWriteLockTimeout - * @deprecated use {@link IndexWriterConfig#getDefaultWriteLockTimeout()} instead - */ - @Deprecated - public static long getDefaultWriteLockTimeout() { - return IndexWriterConfig.getDefaultWriteLockTimeout(); - } - - /** * Commits all changes to an index and closes all * associated files. Note that this may be a costly * operation, so, try to re-use a single writer instead of @@ -3030,7 +2302,7 @@ } // Now create the compound file if needed - if (mergePolicy instanceof LogMergePolicy && getUseCompoundFile()) { + if (mergePolicy instanceof LogMergePolicy && ((LogMergePolicy) mergePolicy).getUseCompoundFile()) { List- * NOTE: the source directory cannot change while this method is - * running. Otherwise the results are undefined and you could easily hit a - * FileNotFoundException. - *
- * NOTE: this method only copies files that look like index files (ie,
- * have extensions matching the known extensions of index files).
- *
- * @param src source directory
- * @param dest destination directory
- * @param closeDirSrc if true, call {@link #close()} method on
- * source directory
- * @deprecated should be replaced with calls to
- * {@link #copy(Directory, String, String)} for every file that
- * needs copying. You can use the following code:
- *
- *
- * for (String file : src.listAll()) {
- * src.copy(dest, file, file);
- * }
- *
- */
- @Deprecated
- public static void copy(Directory src, Directory dest, boolean closeDirSrc) throws IOException {
- for (String file : src.listAll()) {
- src.copy(dest, file, file);
- }
- if (closeDirSrc) {
- src.close();
- }
- }
-
- /**
* @throws AlreadyClosedException if this Directory is closed
*/
protected final void ensureOpen() throws AlreadyClosedException {
Index: lucene/src/java/org/apache/lucene/store/RAMDirectory.java
===================================================================
--- lucene/src/java/org/apache/lucene/store/RAMDirectory.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/store/RAMDirectory.java (working copy)
@@ -20,6 +20,7 @@
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.Serializable;
+import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -187,6 +188,9 @@
return new RAMFile(this);
}
+ public void sync(Collectionshift bits.
- * This is method is used by {@link LongRangeBuilder}.
- * @param val the numeric value
- * @param shift how many bits to strip from the right
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static String longToPrefixCoded(final long val, final int shift) {
- final BytesRef buffer = new BytesRef(BUF_SIZE_LONG);
- longToPrefixCoded(val, shift, buffer);
- return buffer.utf8ToString();
- }*/
-
- /*
- * This is a convenience method, that returns prefix coded bits of a long without
- * reducing the precision. It can be used to store the full precision value as a
- * stored field in index.
- * To decode, use {@link #prefixCodedToLong}.
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static String longToPrefixCoded(final long val) {
- return longToPrefixCoded(val, 0);
- }*/
-
/**
* Returns prefix coded bits after reducing the precision by shift bits.
* This is method is used by {@link NumericTokenStream}.
@@ -190,46 +164,6 @@
return hash;
}
- /*
- * Returns prefix coded bits after reducing the precision by shift bits.
- * This is method is used by {@link IntRangeBuilder}.
- * @param val the numeric value
- * @param shift how many bits to strip from the right
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static String intToPrefixCoded(final int val, final int shift) {
- final BytesRef buffer = new BytesRef(BUF_SIZE_INT);
- intToPrefixCoded(val, shift, buffer);
- return buffer.utf8ToString();
- }*/
-
- /*
- * This is a convenience method, that returns prefix coded bits of an int without
- * reducing the precision. It can be used to store the full precision value as a
- * stored field in index.
- *
To decode, use {@link #prefixCodedToInt}.
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static String intToPrefixCoded(final int val) {
- return intToPrefixCoded(val, 0);
- }*/
-
- /*
- * Returns a long from prefixCoded characters.
- * Rightmost bits will be zero for lower precision codes.
- * This method can be used to decode e.g. a stored field.
- * @throws NumberFormatException if the supplied string is
- * not correctly prefix encoded.
- * @see #longToPrefixCoded(long)
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static long prefixCodedToLong(final String prefixCoded) {
- return prefixCodedToLong(new BytesRef(prefixCoded));
- }*/
-
/**
* Returns the shift value from a prefix encoded {@code long}.
* @throws NumberFormatException if the supplied {@link BytesRef} is
@@ -278,21 +212,7 @@
return (sortableBits << getPrefixCodedLongShift(val)) ^ 0x8000000000000000L;
}
- /*
- * Returns an int from prefixCoded characters.
- * Rightmost bits will be zero for lower precision codes.
- * This method can be used to decode a term's value.
- * @throws NumberFormatException if the supplied string is
- * not correctly prefix encoded.
- * @see #intToPrefixCoded(int)
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static int prefixCodedToInt(final String prefixCoded) {
- return prefixCodedToInt(new BytesRef(prefixCoded));
- }*/
-
- /*
+ /**
* Returns an int from prefixCoded bytes.
* Rightmost bits will be zero for lower precision codes.
* This method can be used to decode a term's value.
@@ -329,16 +249,6 @@
return f;
}
- /*
- * Convenience method: this just returns:
- * longToPrefixCoded(doubleToSortableLong(val))
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static String doubleToPrefixCoded(double val) {
- return longToPrefixCoded(doubleToSortableLong(val));
- }*/
-
/**
* Converts a sortable long back to a double.
* @see #doubleToSortableLong
@@ -348,16 +258,6 @@
return Double.longBitsToDouble(val);
}
- /*
- * Convenience method: this just returns:
- * sortableLongToDouble(prefixCodedToLong(val))
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static double prefixCodedToDouble(String val) {
- return sortableLongToDouble(prefixCodedToLong(val));
- }*/
-
/**
* Converts a float value to a sortable signed int.
* The value is converted by getting their IEEE 754 floating-point "float format"
@@ -371,16 +271,6 @@
return f;
}
- /*
- * Convenience method: this just returns:
- * intToPrefixCoded(floatToSortableInt(val))
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static String floatToPrefixCoded(float val) {
- return intToPrefixCoded(floatToSortableInt(val));
- }*/
-
/**
* Converts a sortable int back to a float.
* @see #floatToSortableInt
@@ -390,16 +280,6 @@
return Float.intBitsToFloat(val);
}
- /*
- * Convenience method: this just returns:
- * sortableIntToFloat(prefixCodedToInt(val))
- * @deprecated This method is no longer needed!
- *
- @Deprecated
- public static float prefixCodedToFloat(String val) {
- return sortableIntToFloat(prefixCodedToInt(val));
- }*/
-
/**
* Splits a long range recursively.
* You may implement a builder that adds clauses to a
Index: lucene/src/java/org/apache/lucene/document/NumberTools.java
===================================================================
--- lucene/src/java/org/apache/lucene/document/NumberTools.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/document/NumberTools.java (working copy)
@@ -1,140 +0,0 @@
-package org.apache.lucene.document;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.lucene.document.NumericField; // for javadocs
-import org.apache.lucene.search.NumericRangeQuery; // for javadocs
-import org.apache.lucene.util.NumericUtils; // for javadocs
-
-// do not remove this class in 3.0, it may be needed to decode old indexes!
-
-/**
- * Provides support for converting longs to Strings, and back again. The strings
- * are structured so that lexicographic sorting order is preserved.
- *
- *
- * That is, if l1 is less than l2 for any two longs l1 and l2, then - * NumberTools.longToString(l1) is lexicographically less than - * NumberTools.longToString(l2). (Similarly for "greater than" and "equals".) - * - *
- * This class handles all long values (unlike - * {@link org.apache.lucene.document.DateField}). - * - * @deprecated For new indexes use {@link NumericUtils} instead, which - * provides a sortable binary representation (prefix encoded) of numeric - * values. - * To index and efficiently query numeric values use {@link NumericField} - * and {@link NumericRangeQuery}. - * This class is included for use with existing - * indices and will be removed in a future release (possibly Lucene 4.0). - */ -@Deprecated -public class NumberTools { - - private static final int RADIX = 36; - - private static final char NEGATIVE_PREFIX = '-'; - - // NB: NEGATIVE_PREFIX must be < POSITIVE_PREFIX - private static final char POSITIVE_PREFIX = '0'; - - //NB: this must be less than - /** - * Equivalent to longToString(Long.MIN_VALUE) - */ - public static final String MIN_STRING_VALUE = NEGATIVE_PREFIX - + "0000000000000"; - - /** - * Equivalent to longToString(Long.MAX_VALUE) - */ - public static final String MAX_STRING_VALUE = POSITIVE_PREFIX - + "1y2p0ij32e8e7"; - - /** - * The length of (all) strings returned by {@link #longToString} - */ - public static final int STR_SIZE = MIN_STRING_VALUE.length(); - - /** - * Converts a long to a String suitable for indexing. - */ - public static String longToString(long l) { - - if (l == Long.MIN_VALUE) { - // special case, because long is not symmetric around zero - return MIN_STRING_VALUE; - } - - StringBuilder buf = new StringBuilder(STR_SIZE); - - if (l < 0) { - buf.append(NEGATIVE_PREFIX); - l = Long.MAX_VALUE + l + 1; - } else { - buf.append(POSITIVE_PREFIX); - } - String num = Long.toString(l, RADIX); - - int padLen = STR_SIZE - num.length() - buf.length(); - while (padLen-- > 0) { - buf.append('0'); - } - buf.append(num); - - return buf.toString(); - } - - /** - * Converts a String that was returned by {@link #longToString} back to a - * long. - * - * @throws IllegalArgumentException - * if the input is null - * @throws NumberFormatException - * if the input does not parse (it was not a String returned by - * longToString()). - */ - public static long stringToLong(String str) { - if (str == null) { - throw new NullPointerException("string cannot be null"); - } - if (str.length() != STR_SIZE) { - throw new NumberFormatException("string is the wrong size"); - } - - if (str.equals(MIN_STRING_VALUE)) { - return Long.MIN_VALUE; - } - - char prefix = str.charAt(0); - long l = Long.parseLong(str.substring(1), RADIX); - - if (prefix == POSITIVE_PREFIX) { - // nop - } else if (prefix == NEGATIVE_PREFIX) { - l = l - Long.MAX_VALUE - 1; - } else { - throw new NumberFormatException( - "string does not begin with the correct prefix"); - } - - return l; - } -} \ No newline at end of file Index: lucene/src/java/org/apache/lucene/document/DateField.java =================================================================== --- lucene/src/java/org/apache/lucene/document/DateField.java (revision 1040383) +++ lucene/src/java/org/apache/lucene/document/DateField.java (working copy) @@ -1,123 +0,0 @@ -package org.apache.lucene.document; - -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import org.apache.lucene.search.PrefixQuery; -import org.apache.lucene.search.TermRangeQuery; -import org.apache.lucene.search.NumericRangeQuery; // for javadocs -import org.apache.lucene.util.NumericUtils; // for javadocs - -import java.util.Date; // for javadoc -import java.util.Calendar; // for javadoc - -// do not remove in 3.0, needed for reading old indexes! - -/** - * Provides support for converting dates to strings and vice-versa. - * The strings are structured so that lexicographic sorting orders by date, - * which makes them suitable for use as field values and search terms. - * - *
Note that this class saves dates with millisecond granularity, - * which is bad for {@link TermRangeQuery} and {@link PrefixQuery}, as those - * queries are expanded to a BooleanQuery with a potentially large number - * of terms when searching. Thus you might want to use - * {@link DateTools} instead. - * - *
- * Note: dates before 1970 cannot be used, and therefore cannot be - * indexed when using this class. See {@link DateTools} for an - * alternative without such a limitation. - * - *
- * Another approach is {@link NumericUtils}, which provides
- * a sortable binary representation (prefix encoded) of numeric values, which
- * date/time are.
- * For indexing a {@link Date} or {@link Calendar}, just get the unix timestamp as
- * long using {@link Date#getTime} or {@link Calendar#getTimeInMillis} and
- * index this as a numeric value with {@link NumericField}
- * and use {@link NumericRangeQuery} to query it.
- *
- * @deprecated If you build a new index, use {@link DateTools} or
- * {@link NumericField} instead.
- * This class is included for use with existing
- * indices and will be removed in a future release (possibly Lucene 4.0).
- */
-@Deprecated
-public class DateField {
-
- private DateField() {}
-
- // make date strings long enough to last a millenium
- private static int DATE_LEN = Long.toString(1000L*365*24*60*60*1000,
- Character.MAX_RADIX).length();
-
- public static String MIN_DATE_STRING() {
- return timeToString(0);
- }
-
- public static String MAX_DATE_STRING() {
- char[] buffer = new char[DATE_LEN];
- char c = Character.forDigit(Character.MAX_RADIX-1, Character.MAX_RADIX);
- for (int i = 0 ; i < DATE_LEN; i++)
- buffer[i] = c;
- return new String(buffer);
- }
-
- /**
- * Converts a Date to a string suitable for indexing.
- * @throws RuntimeException if the date specified in the
- * method argument is before 1970
- */
- public static String dateToString(Date date) {
- return timeToString(date.getTime());
- }
- /**
- * Converts a millisecond time to a string suitable for indexing.
- * @throws RuntimeException if the time specified in the
- * method argument is negative, that is, before 1970
- */
- public static String timeToString(long time) {
- if (time < 0)
- throw new RuntimeException("time '" + time + "' is too early, must be >= 0");
-
- String s = Long.toString(time, Character.MAX_RADIX);
-
- if (s.length() > DATE_LEN)
- throw new RuntimeException("time '" + time + "' is too late, length of string " +
- "representation must be <= " + DATE_LEN);
-
- // Pad with leading zeros
- if (s.length() < DATE_LEN) {
- StringBuilder sb = new StringBuilder(s);
- while (sb.length() < DATE_LEN)
- sb.insert(0, 0);
- s = sb.toString();
- }
-
- return s;
- }
-
- /** Converts a string-encoded date into a millisecond time. */
- public static long stringToTime(String s) {
- return Long.parseLong(s, Character.MAX_RADIX);
- }
- /** Converts a string-encoded date into a Date object. */
- public static Date stringToDate(String s) {
- return new Date(stringToTime(s));
- }
-}
Index: lucene/src/java/org/apache/lucene/document/Field.java
===================================================================
--- lucene/src/java/org/apache/lucene/document/Field.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/document/Field.java (working copy)
@@ -17,13 +17,13 @@
* limitations under the License.
*/
-import org.apache.lucene.analysis.TokenStream;
-import org.apache.lucene.index.IndexWriter; // for javadoc
-import org.apache.lucene.util.StringHelper;
-
import java.io.Reader;
import java.io.Serializable;
+import org.apache.lucene.analysis.TokenStream;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.util.StringHelper;
+
/**
A field is a section of a Document. Each field has two parts, a name and a
value. Values may be free text, provided as a String or as a Reader, or they
@@ -521,25 +521,7 @@
*
* @param name The name of the field
* @param value The binary value
- * @param store Must be Store.YES
- * @throws IllegalArgumentException if store is Store.NO
- * @deprecated Use {@link #Field(String, byte[]) instead}
*/
- @Deprecated
- public Field(String name, byte[] value, Store store) {
- this(name, value, 0, value.length);
-
- if (store == Store.NO) {
- throw new IllegalArgumentException("binary values can't be unstored");
- }
- }
-
- /**
- * Create a stored field with binary value. Optionally the value may be compressed.
- *
- * @param name The name of the field
- * @param value The binary value
- */
public Field(String name, byte[] value) {
this(name, value, 0, value.length);
}
@@ -551,27 +533,7 @@
* @param value The binary value
* @param offset Starting offset in value where this Field's bytes are
* @param length Number of bytes to use for this Field, starting at offset
- * @param store How value should be stored (compressed or not)
- * @throws IllegalArgumentException if store is Store.NO
- * @deprecated Use {@link #Field(String, byte[], int, int) instead}
*/
- @Deprecated
- public Field(String name, byte[] value, int offset, int length, Store store) {
- this(name, value, offset, length);
-
- if (store == Store.NO) {
- throw new IllegalArgumentException("binary values can't be unstored");
- }
- }
-
- /**
- * Create a stored field with binary value. Optionally the value may be compressed.
- *
- * @param name The name of the field
- * @param value The binary value
- * @param offset Starting offset in value where this Field's bytes are
- * @param length Number of bytes to use for this Field, starting at offset
- */
public Field(String name, byte[] value, int offset, int length) {
if (name == null)
Index: lucene/src/java/org/apache/lucene/document/DateTools.java
===================================================================
--- lucene/src/java/org/apache/lucene/document/DateTools.java (revision 1040383)
+++ lucene/src/java/org/apache/lucene/document/DateTools.java (working copy)
@@ -36,10 +36,6 @@
* save dates with a finer resolution than you really need, as then
* RangeQuery and PrefixQuery will require more memory and become slower.
*
- *
Compared to {@link DateField} the strings generated by the methods
- * in this class take slightly more space, unless your selected resolution
- * is set to Resolution.DAY or lower.
- *
*
* Another approach is {@link NumericUtils}, which provides
* a sortable binary representation (prefix encoded) of numeric values, which
Index: lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java
===================================================================
--- lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java (revision 1040383)
+++ lucene/contrib/queryparser/src/test/org/apache/lucene/queryParser/standard/TestQPHelper.java (working copy)
@@ -39,7 +39,6 @@
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-import org.apache.lucene.document.DateField;
import org.apache.lucene.document.DateTools;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@@ -692,12 +691,6 @@
ramDir.close();
}
- /** for testing legacy DateField support */
- private String getLegacyDate(String s) throws Exception {
- DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
- return DateField.dateToString(df.parse(s));
- }
-
/** for testing DateTools support */
private String getDate(String s, DateTools.Resolution resolution)
throws Exception {
@@ -708,11 +701,7 @@
/** for testing DateTools support */
private String getDate(Date d, DateTools.Resolution resolution)
throws Exception {
- if (resolution == null) {
- return DateField.dateToString(d);
- } else {
- return DateTools.dateToString(d, resolution);
- }
+ return DateTools.dateToString(d, resolution);
}
private String escapeDateString(String s) {
@@ -735,21 +724,6 @@
return df.format(calendar.getTime());
}
- /** for testing legacy DateField support */
- public void testLegacyDateRange() throws Exception {
- String startDate = getLocalizedDate(2002, 1, 1);
- String endDate = getLocalizedDate(2002, 1, 4);
- Calendar endDateExpected = new GregorianCalendar();
- endDateExpected.clear();
- endDateExpected.set(2002, 1, 4, 23, 59, 59);
- endDateExpected.set(Calendar.MILLISECOND, 999);
- assertQueryEquals("[ " + escapeDateString(startDate) + " TO " + escapeDateString(endDate) + "]", null, "["
- + getLegacyDate(startDate) + " TO "
- + DateField.dateToString(endDateExpected.getTime()) + "]");
- assertQueryEquals("{ " + escapeDateString(startDate) + " " + escapeDateString(endDate) + " }", null, "{"
- + getLegacyDate(startDate) + " TO " + getLegacyDate(endDate) + "}");
- }
-
public void testDateRange() throws Exception {
String startDate = getLocalizedDate(2002, 1, 1);
String endDate = getLocalizedDate(2002, 1, 4);
@@ -762,20 +736,12 @@
final String hourField = "hour";
StandardQueryParser qp = new StandardQueryParser();
- // Don't set any date resolution and verify if DateField is used
- assertDateRangeQueryEquals(qp, defaultField, startDate, endDate,
- endDateExpected.getTime(), null);
-
Map
- * It will, when parse(String query) is called, construct a query like this
- * (assuming the query consists of two terms and you specify the two fields
- *
- * When setDefaultOperator(AND_OPERATOR) is set, the result will be:
- *
- * When you pass a boost (title=>5 body=>10) you can get
- *
- * In other words, all the query's terms must appear, but it doesn't matter in
- * what fields they appear.
- *
- * It will, when parse(String query) is called, construct a query like this
- * (assuming the query consists of two terms and you specify the two fields
- *
- * When setDefaultOperator(AND_OPERATOR) is set, the result will be:
- *
- * In other words, all the query's terms must appear, but it doesn't matter in
- * what fields they appear.
- *
- * If x fields are specified, this effectively constructs:
- *
- *
- *
- *
- * The code above would construct a query:
- *
- *
- *
- *
- * The code above would construct a query:
- *
- *
- *
- * This class should be used when the new query parser features are needed and
- * also keep at the same time the old query parser interface.
- *
- * @deprecated this class will be removed soon, it's a temporary class to be
- * used along the transition from the old query parser to the new
- * one
- */
-@Deprecated
-public class MultiFieldQueryParserWrapper extends QueryParserWrapper {
-
- /**
- * Creates a MultiFieldQueryParser. Allows passing of a map with term to
- * Boost, and the boost to apply to each term.
- *
- * title and body):
- *
- * (title:term1 body:term1) (title:term2 body:term2)
- *
- *
- *
- * +(title:term1 body:term1) +(title:term2 body:term2)
- *
- *
- *
- * +(title:term1^5.0 body:term1^10.0) +(title:term2^5.0 body:term2^10.0)
- *
- *
- * title and body):
- *
- * (title:term1 body:term1) (title:term2 body:term2)
- *
- *
- *
- * +(title:term1 body:term1) +(title:term2 body:term2)
- *
- *
- *
- * <code>
- * (field1:query1) (field2:query2) (field3:query3)...(fieldx:queryx)
- * </code>
- *
- *
- * @param queries
- * Queries strings to parse
- * @param fields
- * Fields to search on
- * @param analyzer
- * Analyzer to use
- * @throws ParseException
- * if query parsing fails
- * @throws IllegalArgumentException
- * if the length of the queries array differs from the length of the
- * fields array
- */
- public static Query parse(String[] queries, String[] fields, Analyzer analyzer)
- throws ParseException {
- if (queries.length != fields.length)
- throw new IllegalArgumentException("queries.length != fields.length");
- BooleanQuery bQuery = new BooleanQuery();
- for (int i = 0; i < fields.length; i++) {
- QueryParserWrapper qp = new QueryParserWrapper(fields[i], analyzer);
- Query q = qp.parse(queries[i]);
- if (q != null && // q never null, just being defensive
- (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
- bQuery.add(q, BooleanClause.Occur.SHOULD);
- }
- }
- return bQuery;
- }
-
- /**
- * Parses a query, searching on the fields specified. Use this if you need to
- * specify certain fields as required, and others as prohibited.
- *
- * Usage:
- * <code>
- * String[] fields = {"filename", "contents", "description"};
- * BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
- * BooleanClause.Occur.MUST,
- * BooleanClause.Occur.MUST_NOT};
- * MultiFieldQueryParser.parse("query", fields, flags, analyzer);
- * </code>
- *
- *
- * <code>
- * (filename:query) +(contents:query) -(description:query)
- * </code>
- *
- *
- * @param query
- * Query string to parse
- * @param fields
- * Fields to search on
- * @param flags
- * Flags describing the fields
- * @param analyzer
- * Analyzer to use
- * @throws ParseException
- * if query parsing fails
- * @throws IllegalArgumentException
- * if the length of the fields array differs from the length of the
- * flags array
- */
- public static Query parse(String query, String[] fields,
- BooleanClause.Occur[] flags, Analyzer analyzer) throws ParseException {
- if (fields.length != flags.length)
- throw new IllegalArgumentException("fields.length != flags.length");
- BooleanQuery bQuery = new BooleanQuery();
- for (int i = 0; i < fields.length; i++) {
- QueryParserWrapper qp = new QueryParserWrapper(fields[i], analyzer);
- Query q = qp.parse(query);
- if (q != null && // q never null, just being defensive
- (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
- bQuery.add(q, flags[i]);
- }
- }
- return bQuery;
- }
-
- /**
- * Parses a query, searching on the fields specified. Use this if you need to
- * specify certain fields as required, and others as prohibited.
- *
- * Usage:
- * <code>
- * String[] query = {"query1", "query2", "query3"};
- * String[] fields = {"filename", "contents", "description"};
- * BooleanClause.Occur[] flags = {BooleanClause.Occur.SHOULD,
- * BooleanClause.Occur.MUST,
- * BooleanClause.Occur.MUST_NOT};
- * MultiFieldQueryParser.parse(query, fields, flags, analyzer);
- * </code>
- *
- *
- * <code>
- * (filename:query1) +(contents:query2) -(description:query3)
- * </code>
- *
- *
- * @param queries
- * Queries string to parse
- * @param fields
- * Fields to search on
- * @param flags
- * Flags describing the fields
- * @param analyzer
- * Analyzer to use
- * @throws ParseException
- * if query parsing fails
- * @throws IllegalArgumentException
- * if the length of the queries, fields, and flags array differ
- */
- public static Query parse(String[] queries, String[] fields,
- BooleanClause.Occur[] flags, Analyzer analyzer) throws ParseException {
- if (!(queries.length == fields.length && queries.length == flags.length))
- throw new IllegalArgumentException(
- "queries, fields, and flags array have have different length");
- BooleanQuery bQuery = new BooleanQuery();
- for (int i = 0; i < fields.length; i++) {
- QueryParserWrapper qp = new QueryParserWrapper(fields[i], analyzer);
- Query q = qp.parse(queries[i]);
- if (q != null && // q never null, just being defensive
- (!(q instanceof BooleanQuery) || ((BooleanQuery) q).getClauses().length > 0)) {
- bQuery.add(q, flags[i]);
- }
- }
- return bQuery;
- }
-
-}
Index: lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java
===================================================================
--- lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java (revision 1040383)
+++ lucene/contrib/queryparser/src/java/org/apache/lucene/queryParser/standard/QueryParserWrapper.java (working copy)
@@ -1,491 +0,0 @@
-package org.apache.lucene.queryParser.standard;
-
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.text.Collator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.lucene.analysis.Analyzer;
-import org.apache.lucene.document.DateTools;
-import org.apache.lucene.document.DateTools.Resolution;
-import org.apache.lucene.queryParser.ParseException;
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.core.QueryNodeException;
-import org.apache.lucene.queryParser.core.config.FieldConfig;
-import org.apache.lucene.queryParser.core.config.QueryConfigHandler;
-import org.apache.lucene.queryParser.core.nodes.QueryNode;
-import org.apache.lucene.queryParser.core.parser.SyntaxParser;
-import org.apache.lucene.queryParser.core.processors.QueryNodeProcessor;
-import org.apache.lucene.queryParser.standard.builders.StandardQueryBuilder;
-import org.apache.lucene.queryParser.standard.builders.StandardQueryTreeBuilder;
-import org.apache.lucene.queryParser.standard.config.AllowLeadingWildcardAttribute;
-import org.apache.lucene.queryParser.standard.config.AnalyzerAttribute;
-import org.apache.lucene.queryParser.standard.config.DateResolutionAttribute;
-import org.apache.lucene.queryParser.standard.config.DefaultOperatorAttribute;
-import org.apache.lucene.queryParser.standard.config.DefaultPhraseSlopAttribute;
-import org.apache.lucene.queryParser.standard.config.LocaleAttribute;
-import org.apache.lucene.queryParser.standard.config.LowercaseExpandedTermsAttribute;
-import org.apache.lucene.queryParser.standard.config.MultiTermRewriteMethodAttribute;
-import org.apache.lucene.queryParser.standard.config.PositionIncrementsAttribute;
-import org.apache.lucene.queryParser.standard.config.RangeCollatorAttribute;
-import org.apache.lucene.queryParser.standard.config.StandardQueryConfigHandler;
-import org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser;
-import org.apache.lucene.queryParser.standard.processors.StandardQueryNodeProcessorPipeline;
-import org.apache.lucene.search.BooleanClause;
-import org.apache.lucene.search.FuzzyQuery;
-import org.apache.lucene.search.MultiTermQuery;
-import org.apache.lucene.search.Query;
-
-/**
- * This class performs the query parsing using the new query parser
- * implementation, but keeps the old {@link QueryParser} API.
- *
- * This class should be used when the new query parser features are and the old
- * {@link QueryParser} API are needed at the same time.
- *
- * @deprecated this class will be removed soon, it's a temporary class to be
- * used along the transition from the old query parser to the new
- * one
- */
-@Deprecated
-public class QueryParserWrapper {
-
- /**
- * The default operator for parsing queries. Use
- * {@link QueryParserWrapper#setDefaultOperator} to change it.
- */
- static public enum Operator { OR, AND }
-
- // the nested class:
- /** Alternative form of QueryParser.Operator.AND */
- public static final Operator AND_OPERATOR = Operator.AND;
-
- /** Alternative form of QueryParser.Operator.OR */
- public static final Operator OR_OPERATOR = Operator.OR;
-
- /**
- * Returns a String where those characters that QueryParser expects to be
- * escaped are escaped by a preceding \.
- */
- public static String escape(String s) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < s.length(); i++) {
- char c = s.charAt(i);
- // These characters are part of the query syntax and must be escaped
- if (c == '\\' || c == '+' || c == '-' || c == '!' || c == '(' || c == ')'
- || c == ':' || c == '^' || c == '[' || c == ']' || c == '\"'
- || c == '{' || c == '}' || c == '~' || c == '*' || c == '?'
- || c == '|' || c == '&') {
- sb.append('\\');
- }
- sb.append(c);
- }
- return sb.toString();
- }
-
- private SyntaxParser syntaxParser = new StandardSyntaxParser();
-
- private StandardQueryConfigHandler config;
-
- private StandardQueryParser qpHelper;
-
- private QueryNodeProcessor processorPipeline;
-
- private StandardQueryBuilder builder = new StandardQueryTreeBuilder();
-
- private String defaultField;
-
- public QueryParserWrapper(String defaultField, Analyzer analyzer) {
- this.defaultField = defaultField;
-
- this.qpHelper = new StandardQueryParser();
-
- this.config = (StandardQueryConfigHandler) qpHelper.getQueryConfigHandler();
-
- this.qpHelper.setAnalyzer(analyzer);
-
- this.processorPipeline = new StandardQueryNodeProcessorPipeline(this.config);
-
- }
-
- StandardQueryParser getQueryParserHelper() {
- return qpHelper;
- }
-
- public String getField() {
- return this.defaultField;
- }
-
- public Analyzer getAnalyzer() {
-
- if (this.config != null
- && this.config.hasAttribute(AnalyzerAttribute.class)) {
-
- return this.config.getAttribute(AnalyzerAttribute.class).getAnalyzer();
-
- }
-
- return null;
-
- }
-
- /**
- * Sets the {@link StandardQueryBuilder} used to generate a {@link Query}
- * object from the parsed and processed query node tree.
- *
- * @param builder the builder
- */
- public void setQueryBuilder(StandardQueryBuilder builder) {
- this.builder = builder;
- }
-
- /**
- * Sets the {@link QueryNodeProcessor} used to process the query node tree
- * generated by the
- * {@link org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser}.
- *
- * @param processor the processor
- */
- public void setQueryProcessor(QueryNodeProcessor processor) {
- this.processorPipeline = processor;
- this.processorPipeline.setQueryConfigHandler(this.config);
-
- }
-
- /**
- * Sets the {@link QueryConfigHandler} used by the {@link QueryNodeProcessor}
- * set to this object.
- *
- * @param queryConfig the query config handler
- */
- public void setQueryConfig(StandardQueryConfigHandler queryConfig) {
- this.config = queryConfig;
-
- if (this.processorPipeline != null) {
- this.processorPipeline.setQueryConfigHandler(this.config);
- }
-
- }
-
- /**
- * Returns the query config handler used by this query parser
- *
- * @return the query config handler
- */
- public QueryConfigHandler getQueryConfigHandler() {
- return this.config;
- }
-
- /**
- * Returns {@link QueryNodeProcessor} used to process the query node tree
- * generated by the
- * {@link org.apache.lucene.queryParser.standard.parser.StandardSyntaxParser}.
- *
- * @return the query processor
- */
- public QueryNodeProcessor getQueryProcessor() {
- return this.processorPipeline;
- }
-
- public ParseException generateParseException() {
- return null;
- }
-
- public boolean getAllowLeadingWildcard() {
-
- if (this.config != null
- && this.config.hasAttribute(AllowLeadingWildcardAttribute.class)) {
-
- return this.config.getAttribute(AllowLeadingWildcardAttribute.class)
- .isAllowLeadingWildcard();
-
- }
-
- return false;
-
- }
-
- public MultiTermQuery.RewriteMethod getMultiTermRewriteMethod() {
-
- if (this.config != null
- && this.config.hasAttribute(MultiTermRewriteMethodAttribute.class)) {
-
- return this.config.getAttribute(MultiTermRewriteMethodAttribute.class)
- .getMultiTermRewriteMethod();
-
- }
-
- return MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT;
-
- }
-
- public Resolution getDateResolution(String fieldName) {
-
- if (this.config != null) {
- FieldConfig fieldConfig = this.config.getFieldConfig(fieldName);
-
- if (fieldConfig != null) {
-
- if (this.config.hasAttribute(DateResolutionAttribute.class)) {
-
- return this.config.getAttribute(DateResolutionAttribute.class)
- .getDateResolution();
-
- }
-
- }
-
- }
-
- return null;
-
- }
-
- public boolean getEnablePositionIncrements() {
-
- if (this.config != null
- && this.config.hasAttribute(PositionIncrementsAttribute.class)) {
-
- return this.config.getAttribute(PositionIncrementsAttribute.class)
- .isPositionIncrementsEnabled();
-
- }
-
- return false;
-
- }
-
- public float getFuzzyMinSim() {
- return FuzzyQuery.defaultMinSimilarity;
- }
-
- public int getFuzzyPrefixLength() {
- return FuzzyQuery.defaultPrefixLength;
- }
-
- public Locale getLocale() {
-
- if (this.config != null && this.config.hasAttribute(LocaleAttribute.class)) {
- return this.config.getAttribute(LocaleAttribute.class).getLocale();
- }
-
- return Locale.getDefault();
-
- }
-
- public boolean getLowercaseExpandedTerms() {
-
- if (this.config != null
- && this.config.hasAttribute(LowercaseExpandedTermsAttribute.class)) {
-
- return this.config.getAttribute(LowercaseExpandedTermsAttribute.class)
- .isLowercaseExpandedTerms();
-
- }
-
- return true;
-
- }
-
- public int getPhraseSlop() {
-
- if (this.config != null
- && this.config.hasAttribute(AllowLeadingWildcardAttribute.class)) {
-
- return this.config.getAttribute(DefaultPhraseSlopAttribute.class)
- .getDefaultPhraseSlop();
-
- }
-
- return 0;
-
- }
-
- public Collator getRangeCollator() {
-
- if (this.config != null
- && this.config.hasAttribute(RangeCollatorAttribute.class)) {
-
- return this.config.getAttribute(RangeCollatorAttribute.class)
- .getRangeCollator();
-
- }
-
- return null;
-
- }
-
- public boolean getUseOldRangeQuery() {
- if (getMultiTermRewriteMethod() == MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE) {
- return true;
- } else {
- return false;
- }
- }
-
- public Query parse(String query) throws ParseException {
-
- try {
- QueryNode queryTree = this.syntaxParser.parse(query, getField());
- queryTree = this.processorPipeline.process(queryTree);
- return this.builder.build(queryTree);
-
- } catch (QueryNodeException e) {
- throw new ParseException("parse exception");
- }
-
- }
-
- public void setAllowLeadingWildcard(boolean allowLeadingWildcard) {
- this.qpHelper.setAllowLeadingWildcard(allowLeadingWildcard);
- }
-
- public void setMultiTermRewriteMethod(MultiTermQuery.RewriteMethod method) {
- this.qpHelper.setMultiTermRewriteMethod(method);
- }
-
- public void setDateResolution(Resolution dateResolution) {
- this.qpHelper.setDateResolution(dateResolution);
- }
-
- private Map
-There are 2 wrapper classes that extends QueryParser and MultiFieldQueryParser. -The classes implement internally the new query parser structure. These 2 -classes are deprecated and should only be used when there is a need to use the -old query parser interface. -
-