mirror of https://github.com/apache/lucene.git
LUCENE-5850: Made Version handling more robust and extensible
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1618263 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7dc2b104b1
commit
73bb9c91d9
|
@ -143,7 +143,7 @@
|
||||||
</subant>
|
</subant>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<property name="version" value="5.0-SNAPSHOT"/>
|
<property name="version" value="5.0.0-SNAPSHOT"/>
|
||||||
<property name="maven-build-dir" value="maven-build"/>
|
<property name="maven-build-dir" value="maven-build"/>
|
||||||
<property name="maven-version" value="2.2.1"/>
|
<property name="maven-version" value="2.2.1"/>
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
<module name="lucene-core-tests" />
|
<module name="lucene-core-tests" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/lucene/core" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/lucene/core" />
|
||||||
<option name="VM_PARAMETERS" value="-Xmx256m -ea -Dlucene.version=5.0-SNAPSHOT -DtempDir=temp" />
|
<option name="VM_PARAMETERS" value="-Xmx256m -ea -Dversion.base=5.0.0 -DtempDir=temp" />
|
||||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="false" name="Module analyzers-common" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Module analyzers-common" type="JUnit" factoryName="JUnit">
|
||||||
|
@ -183,28 +183,28 @@
|
||||||
<module name="solr-core-tests" />
|
<module name="solr-core-tests" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/solr-core" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/solr-core" />
|
||||||
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
||||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="false" name="Solrj" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Solrj" type="JUnit" factoryName="JUnit">
|
||||||
<module name="solrj-tests" />
|
<module name="solrj-tests" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/solr-solrj" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/solr-solrj" />
|
||||||
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
||||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="false" name="Solr analysis-extras contrib" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Solr analysis-extras contrib" type="JUnit" factoryName="JUnit">
|
||||||
<module name="analysis-extras" />
|
<module name="analysis-extras" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/solr-analysis-extras" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/solr-analysis-extras" />
|
||||||
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
||||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="false" name="Solr clustering contrib" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Solr clustering contrib" type="JUnit" factoryName="JUnit">
|
||||||
<module name="clustering" />
|
<module name="clustering" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/solr-clustering" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/solr-clustering" />
|
||||||
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
||||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="false" name="Solr dataimporthandler contrib" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Solr dataimporthandler contrib" type="JUnit" factoryName="JUnit">
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
<module name="uima" />
|
<module name="uima" />
|
||||||
<option name="TEST_OBJECT" value="package" />
|
<option name="TEST_OBJECT" value="package" />
|
||||||
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/solr-uima" />
|
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/idea-build/solr/contrib/solr-uima" />
|
||||||
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
<option name="VM_PARAMETERS" value="-ea -Dtests.luceneMatchVersion=5.0.0 -DtempDir=temp -Djetty.testMode=1 -Djetty.insecurerandom=1 -Dsolr.directoryFactory=org.apache.solr.core.MockDirectoryFactory" />
|
||||||
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
<option name="TEST_SEARCH_SCOPE"><value defaultName="singleModule" /></option>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration default="false" name="Solr velocity contrib" type="JUnit" factoryName="JUnit">
|
<configuration default="false" name="Solr velocity contrib" type="JUnit" factoryName="JUnit">
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<tests.codec>random</tests.codec>
|
<tests.codec>random</tests.codec>
|
||||||
<tests.directory>random</tests.directory>
|
<tests.directory>random</tests.directory>
|
||||||
<tests.locale>random</tests.locale>
|
<tests.locale>random</tests.locale>
|
||||||
<tests.luceneMatchVersion>5.0</tests.luceneMatchVersion>
|
<tests.luceneMatchVersion>5.0.0</tests.luceneMatchVersion>
|
||||||
<tests.multiplier>1</tests.multiplier>
|
<tests.multiplier>1</tests.multiplier>
|
||||||
<tests.nightly>false</tests.nightly>
|
<tests.nightly>false</tests.nightly>
|
||||||
<tests.postingsformat>random</tests.postingsformat>
|
<tests.postingsformat>random</tests.postingsformat>
|
||||||
|
|
|
@ -161,8 +161,8 @@ API Changes
|
||||||
CoveredBy. The area requirement on the predicates was removed, and Overlaps' definition
|
CoveredBy. The area requirement on the predicates was removed, and Overlaps' definition
|
||||||
was fixed. (David Smiley)
|
was fixed. (David Smiley)
|
||||||
|
|
||||||
* LUCENE-5850: CheckIndex now prints the Lucene version used to write
|
* LUCENE-5850: Made Version handling more robust and extensible. Deprecated Constants.LUCENE_MAIN_VERSION, Constants.LUCENE_VERSION and current Version constants of the form LUCENE_X_Y. Added version constants that include bugfix number of form LUCENE_X_Y_Z. Changed Version.LUCENE_CURRENT to Version.LATEST. CheckIndex now prints the Lucene version used to write
|
||||||
each segment. (Robert Muir, Mike McCandless)
|
each segment. (Ryan Ernst, Uwe Schindler, Robert Muir, Mike McCandless)
|
||||||
|
|
||||||
* LUCENE-5836: BytesRef has been splitted into BytesRef, whose intended usage is
|
* LUCENE-5836: BytesRef has been splitted into BytesRef, whose intended usage is
|
||||||
to be just a reference to a section of a larger byte[] and BytesRefBuilder
|
to be just a reference to a section of a larger byte[] and BytesRefBuilder
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class DictionaryCompoundWordTokenFilterFactory extends TokenFilterFactory
|
||||||
if (dictionary == null) {
|
if (dictionary == null) {
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
return new DictionaryCompoundWordTokenFilter(input, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
return new DictionaryCompoundWordTokenFilter(input, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
||||||
}
|
}
|
||||||
return new Lucene43DictionaryCompoundWordTokenFilter(input, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
return new Lucene43DictionaryCompoundWordTokenFilter(input, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class HyphenationCompoundWordTokenFilterFactory extends TokenFilterFactor
|
||||||
final InputSource is = new InputSource(stream);
|
final InputSource is = new InputSource(stream);
|
||||||
is.setEncoding(encoding); // if it's null let xml parser decide
|
is.setEncoding(encoding); // if it's null let xml parser decide
|
||||||
is.setSystemId(hypFile);
|
is.setSystemId(hypFile);
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
hyphenator = HyphenationCompoundWordTokenFilter.getHyphenationTree(is);
|
hyphenator = HyphenationCompoundWordTokenFilter.getHyphenationTree(is);
|
||||||
} else {
|
} else {
|
||||||
hyphenator = Lucene43HyphenationCompoundWordTokenFilter.getHyphenationTree(is);
|
hyphenator = Lucene43HyphenationCompoundWordTokenFilter.getHyphenationTree(is);
|
||||||
|
@ -111,7 +111,7 @@ public class HyphenationCompoundWordTokenFilterFactory extends TokenFilterFactor
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TokenFilter create(TokenStream input) {
|
public TokenFilter create(TokenStream input) {
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
return new HyphenationCompoundWordTokenFilter(input, hyphenator, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
return new HyphenationCompoundWordTokenFilter(input, hyphenator, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
||||||
}
|
}
|
||||||
return new Lucene43HyphenationCompoundWordTokenFilter(input, hyphenator, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
return new Lucene43HyphenationCompoundWordTokenFilter(input, hyphenator, dictionary, minWordSize, minSubwordSize, maxSubwordSize, onlyLongestMatch);
|
||||||
|
|
|
@ -118,7 +118,7 @@ public class WordDelimiterFilterFactory extends TokenFilterFactory implements Re
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TokenFilter create(TokenStream input) {
|
public TokenFilter create(TokenStream input) {
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_8)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_8_0)) {
|
||||||
return new WordDelimiterFilter(input, typeTable == null ? WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE : typeTable,
|
return new WordDelimiterFilter(input, typeTable == null ? WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE : typeTable,
|
||||||
flags, protectedWords);
|
flags, protectedWords);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class EdgeNGramFilterFactory extends TokenFilterFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TokenFilter create(TokenStream input) {
|
public TokenFilter create(TokenStream input) {
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
return new EdgeNGramTokenFilter(input, minGramSize, maxGramSize);
|
return new EdgeNGramTokenFilter(input, minGramSize, maxGramSize);
|
||||||
}
|
}
|
||||||
return new Lucene43EdgeNGramTokenFilter(input, minGramSize, maxGramSize);
|
return new Lucene43EdgeNGramTokenFilter(input, minGramSize, maxGramSize);
|
||||||
|
|
|
@ -22,7 +22,6 @@ import org.apache.lucene.analysis.util.TokenizerFactory;
|
||||||
import org.apache.lucene.util.AttributeFactory;
|
import org.apache.lucene.util.AttributeFactory;
|
||||||
import org.apache.lucene.util.Version;
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,7 +49,7 @@ public class EdgeNGramTokenizerFactory extends TokenizerFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Tokenizer create(AttributeFactory factory) {
|
public Tokenizer create(AttributeFactory factory) {
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
return new EdgeNGramTokenizer(factory, minGramSize, maxGramSize);
|
return new EdgeNGramTokenizer(factory, minGramSize, maxGramSize);
|
||||||
}
|
}
|
||||||
return new Lucene43NGramTokenizer(factory, minGramSize, maxGramSize);
|
return new Lucene43NGramTokenizer(factory, minGramSize, maxGramSize);
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class NGramFilterFactory extends TokenFilterFactory {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TokenFilter create(TokenStream input) {
|
public TokenFilter create(TokenStream input) {
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
return new NGramTokenFilter(input, minGramSize, maxGramSize);
|
return new NGramTokenFilter(input, minGramSize, maxGramSize);
|
||||||
}
|
}
|
||||||
return new Lucene43NGramTokenFilter(input, minGramSize, maxGramSize);
|
return new Lucene43NGramTokenFilter(input, minGramSize, maxGramSize);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class NGramTokenizerFactory extends TokenizerFactory {
|
||||||
/** Creates the {@link TokenStream} of n-grams from the given {@link Reader} and {@link AttributeFactory}. */
|
/** Creates the {@link TokenStream} of n-grams from the given {@link Reader} and {@link AttributeFactory}. */
|
||||||
@Override
|
@Override
|
||||||
public Tokenizer create(AttributeFactory factory) {
|
public Tokenizer create(AttributeFactory factory) {
|
||||||
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
return new NGramTokenizer(factory, minGramSize, maxGramSize);
|
return new NGramTokenizer(factory, minGramSize, maxGramSize);
|
||||||
} else {
|
} else {
|
||||||
return new Lucene43NGramTokenizer(factory, minGramSize, maxGramSize);
|
return new Lucene43NGramTokenizer(factory, minGramSize, maxGramSize);
|
||||||
|
|
|
@ -98,7 +98,7 @@ public final class ThaiAnalyzer extends StopwordAnalyzerBase {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected TokenStreamComponents createComponents(String fieldName) {
|
protected TokenStreamComponents createComponents(String fieldName) {
|
||||||
if (getVersion().onOrAfter(Version.LUCENE_4_8)) {
|
if (getVersion().onOrAfter(Version.LUCENE_4_8_0)) {
|
||||||
final Tokenizer source = new ThaiTokenizer();
|
final Tokenizer source = new ThaiTokenizer();
|
||||||
TokenStream result = new LowerCaseFilter(source);
|
TokenStream result = new LowerCaseFilter(source);
|
||||||
result = new StopFilter(result, stopwords);
|
result = new StopFilter(result, stopwords);
|
||||||
|
|
|
@ -119,7 +119,7 @@ public final class TurkishAnalyzer extends StopwordAnalyzerBase {
|
||||||
protected TokenStreamComponents createComponents(String fieldName) {
|
protected TokenStreamComponents createComponents(String fieldName) {
|
||||||
final Tokenizer source = new StandardTokenizer();
|
final Tokenizer source = new StandardTokenizer();
|
||||||
TokenStream result = new StandardFilter(source);
|
TokenStream result = new StandardFilter(source);
|
||||||
if (getVersion().onOrAfter(Version.LUCENE_4_8)) {
|
if (getVersion().onOrAfter(Version.LUCENE_4_8_0)) {
|
||||||
result = new ApostropheFilter(result);
|
result = new ApostropheFilter(result);
|
||||||
}
|
}
|
||||||
result = new TurkishLowerCaseFilter(result);
|
result = new TurkishLowerCaseFilter(result);
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class TestGermanAnalyzer extends BaseTokenStreamTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** test some features of the new snowball filter
|
/** test some features of the new snowball filter
|
||||||
* these only pass with LUCENE_CURRENT, not if you use o.a.l.a.de.GermanStemmer
|
* these only pass with LATEST, not if you use o.a.l.a.de.GermanStemmer
|
||||||
*/
|
*/
|
||||||
public void testGermanSpecials() throws Exception {
|
public void testGermanSpecials() throws Exception {
|
||||||
GermanAnalyzer a = new GermanAnalyzer();
|
GermanAnalyzer a = new GermanAnalyzer();
|
||||||
|
|
|
@ -132,7 +132,7 @@ public final class SmartChineseAnalyzer extends Analyzer {
|
||||||
public TokenStreamComponents createComponents(String fieldName) {
|
public TokenStreamComponents createComponents(String fieldName) {
|
||||||
final Tokenizer tokenizer;
|
final Tokenizer tokenizer;
|
||||||
TokenStream result;
|
TokenStream result;
|
||||||
if (getVersion().onOrAfter(Version.LUCENE_4_8)) {
|
if (getVersion().onOrAfter(Version.LUCENE_4_8_0)) {
|
||||||
tokenizer = new HMMChineseTokenizer();
|
tokenizer = new HMMChineseTokenizer();
|
||||||
result = tokenizer;
|
result = tokenizer;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -59,7 +59,7 @@ import java.util.regex.Pattern;
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* Each component analysis factory map specify <tt>luceneMatchVersion</tt> (defaults to
|
* Each component analysis factory map specify <tt>luceneMatchVersion</tt> (defaults to
|
||||||
* {@link Version#LUCENE_CURRENT}) and any of the args understood by the specified
|
* {@link Version#LATEST}) and any of the args understood by the specified
|
||||||
* *Factory class, in the above-describe param format.
|
* *Factory class, in the above-describe param format.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Example:
|
* Example:
|
||||||
|
@ -68,7 +68,7 @@ import java.util.regex.Pattern;
|
||||||
* positionIncrementGap:100,
|
* positionIncrementGap:100,
|
||||||
* HTMLStripCharFilter,
|
* HTMLStripCharFilter,
|
||||||
* MappingCharFilter(mapping:'mapping-FoldToASCII.txt'),
|
* MappingCharFilter(mapping:'mapping-FoldToASCII.txt'),
|
||||||
* WhitespaceTokenizer(luceneMatchVersion:LUCENE_5_0),
|
* WhitespaceTokenizer(luceneMatchVersion:LUCENE_5_0_0),
|
||||||
* TokenLimitFilter(maxTokenCount:10000, consumeAllTokens:false))
|
* TokenLimitFilter(maxTokenCount:10000, consumeAllTokens:false))
|
||||||
* [...]
|
* [...]
|
||||||
* -NewAnalyzer('strip html, fold to ascii, whitespace tokenize, max 10k tokens')
|
* -NewAnalyzer('strip html, fold to ascii, whitespace tokenize, max 10k tokens')
|
||||||
|
@ -355,7 +355,7 @@ public class AnalyzerFactoryTask extends PerfTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!argMap.containsKey("luceneMatchVersion")) {
|
if (!argMap.containsKey("luceneMatchVersion")) {
|
||||||
argMap.put("luceneMatchVersion", Version.LUCENE_CURRENT.toString());
|
argMap.put("luceneMatchVersion", Version.LATEST.toString());
|
||||||
}
|
}
|
||||||
final AbstractAnalysisFactory instance;
|
final AbstractAnalysisFactory instance;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -16,9 +16,6 @@ package org.apache.lucene.benchmark.byTask.tasks;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.lucene.analysis.Analyzer;
|
import org.apache.lucene.analysis.Analyzer;
|
||||||
import org.apache.lucene.analysis.util.CharFilterFactory;
|
|
||||||
import org.apache.lucene.analysis.util.TokenFilterFactory;
|
|
||||||
import org.apache.lucene.analysis.util.TokenizerFactory;
|
|
||||||
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
import org.apache.lucene.benchmark.byTask.PerfRunData;
|
||||||
import org.apache.lucene.benchmark.byTask.utils.AnalyzerFactory;
|
import org.apache.lucene.benchmark.byTask.utils.AnalyzerFactory;
|
||||||
import org.apache.lucene.util.Version;
|
import org.apache.lucene.util.Version;
|
||||||
|
@ -47,7 +44,7 @@ public class NewAnalyzerTask extends PerfTask {
|
||||||
try {
|
try {
|
||||||
// first try to use a ctor with version parameter (needed for many new Analyzers that have no default one anymore
|
// first try to use a ctor with version parameter (needed for many new Analyzers that have no default one anymore
|
||||||
Constructor<? extends Analyzer> cnstr = clazz.getConstructor(Version.class);
|
Constructor<? extends Analyzer> cnstr = clazz.getConstructor(Version.class);
|
||||||
return cnstr.newInstance(Version.LUCENE_CURRENT);
|
return cnstr.newInstance(Version.LATEST);
|
||||||
} catch (NoSuchMethodException nsme) {
|
} catch (NoSuchMethodException nsme) {
|
||||||
// otherwise use default ctor
|
// otherwise use default ctor
|
||||||
return clazz.newInstance();
|
return clazz.newInstance();
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class CreateIndexTaskTest extends BenchmarkTestCase {
|
||||||
private PerfRunData createPerfRunData(String infoStreamValue) throws Exception {
|
private PerfRunData createPerfRunData(String infoStreamValue) throws Exception {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
props.setProperty("writer.version", Version.LUCENE_5_0.toString());
|
props.setProperty("writer.version", Version.LUCENE_5_0_0.toString());
|
||||||
props.setProperty("print.props", "false"); // don't print anything
|
props.setProperty("print.props", "false"); // don't print anything
|
||||||
props.setProperty("directory", "RAMDirectory");
|
props.setProperty("directory", "RAMDirectory");
|
||||||
if (infoStreamValue != null) {
|
if (infoStreamValue != null) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.util.BytesRefBuilder;
|
import org.apache.lucene.util.BytesRefBuilder;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.StringHelper;
|
import org.apache.lucene.util.StringHelper;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reads plaintext segments files
|
* reads plaintext segments files
|
||||||
|
@ -60,7 +61,7 @@ public class SimpleTextSegmentInfoReader extends SegmentInfoReader {
|
||||||
try {
|
try {
|
||||||
SimpleTextUtil.readLine(input, scratch);
|
SimpleTextUtil.readLine(input, scratch);
|
||||||
assert StringHelper.startsWith(scratch.get(), SI_VERSION);
|
assert StringHelper.startsWith(scratch.get(), SI_VERSION);
|
||||||
final String version = readString(SI_VERSION.length, scratch);
|
final Version version = Version.parse(readString(SI_VERSION.length, scratch));
|
||||||
|
|
||||||
SimpleTextUtil.readLine(input, scratch);
|
SimpleTextUtil.readLine(input, scratch);
|
||||||
assert StringHelper.startsWith(scratch.get(), SI_DOCCOUNT);
|
assert StringHelper.startsWith(scratch.get(), SI_DOCCOUNT);
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class SimpleTextSegmentInfoWriter extends SegmentInfoWriter {
|
||||||
BytesRefBuilder scratch = new BytesRefBuilder();
|
BytesRefBuilder scratch = new BytesRefBuilder();
|
||||||
|
|
||||||
SimpleTextUtil.write(output, SI_VERSION);
|
SimpleTextUtil.write(output, SI_VERSION);
|
||||||
SimpleTextUtil.write(output, si.getVersion(), scratch);
|
SimpleTextUtil.write(output, si.getVersion().toString(), scratch);
|
||||||
SimpleTextUtil.writeNewline(output);
|
SimpleTextUtil.writeNewline(output);
|
||||||
|
|
||||||
SimpleTextUtil.write(output, SI_DOCCOUNT);
|
SimpleTextUtil.write(output, SI_DOCCOUNT);
|
||||||
|
|
|
@ -26,6 +26,14 @@
|
||||||
for standalone use.
|
for standalone use.
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
<!-- !!! RELEASE MANAGER: Change version numbers only here: !!! -->
|
||||||
|
|
||||||
|
<!-- The base version of the next release (including bugfix number, e.g., x.y.z+): -->
|
||||||
|
<property name="version.base" value="5.0.0"/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- !!! RELEASE MANAGER: Don't change anything after this line! !!! -->
|
||||||
|
|
||||||
<dirname file="${ant.file.common}" property="common.dir"/>
|
<dirname file="${ant.file.common}" property="common.dir"/>
|
||||||
<property name="dev-tools.dir" location="${common.dir}/../dev-tools"/>
|
<property name="dev-tools.dir" location="${common.dir}/../dev-tools"/>
|
||||||
<property name="prettify.dir" location="${common.dir}/tools/prettify"/>
|
<property name="prettify.dir" location="${common.dir}/tools/prettify"/>
|
||||||
|
@ -48,14 +56,31 @@
|
||||||
</tstamp>
|
</tstamp>
|
||||||
|
|
||||||
<property name="Name" value="Lucene"/>
|
<property name="Name" value="Lucene"/>
|
||||||
|
|
||||||
<property name="name" value="${ant.project.name}"/>
|
<property name="name" value="${ant.project.name}"/>
|
||||||
<property name="tests.luceneMatchVersion" value="5.0"/>
|
|
||||||
<property name="dev.version.base" value="5.0"/>
|
<!--TODO: remove once Jenkins jobs are updated:--><property name="dev.version.suffix" value="SNAPSHOT"/>
|
||||||
<property name="dev.version.suffix" value="SNAPSHOT"/>
|
|
||||||
<property name="dev.version" value="${dev.version.base}-${dev.version.suffix}"/>
|
<!-- The corresponding version as oal.util.Version used for matchVersion (x.y): -->
|
||||||
<property name="version" value="${dev.version}"/>
|
<property name="version.luceneMatchVersion" value="${version.base}"/>
|
||||||
<property name="spec.version" value="${version}"/>
|
<!-- Suffix of the version, by default SNAPSHOT: -->
|
||||||
|
<property name="version.suffix" value="${dev.version.suffix}"/>
|
||||||
|
<property name="version" value="${version.base}-${version.suffix}"/>
|
||||||
|
|
||||||
|
|
||||||
|
<fail message="If you pass -Dversion=... to set a release version, it must match "${version.base}", optionally followed by a suffix (e.g., "-SNAPSHOT").">
|
||||||
|
<condition>
|
||||||
|
<not><matches pattern="^\Q${version.base}\E(|\-.*)$" casesensitive="true" string="${version}"/></not>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
|
||||||
|
<fail message="Invalid version.luceneMatchVersion property: ${version.luceneMatchVersion}">
|
||||||
|
<condition>
|
||||||
|
<not><and>
|
||||||
|
<matches pattern="^\d+\.\d+\.\d+$" casesensitive="true" string="${version.luceneMatchVersion}"/>
|
||||||
|
<matches pattern="^\Q${version.luceneMatchVersion}\E(\.|\-|\b).*$" casesensitive="true" string="${version}"/>
|
||||||
|
</and></not>
|
||||||
|
</condition>
|
||||||
|
</fail>
|
||||||
|
|
||||||
<property name="year" value="2000-${current.year}"/>
|
<property name="year" value="2000-${current.year}"/>
|
||||||
|
|
||||||
|
@ -118,6 +143,7 @@
|
||||||
<property name="tests.verbose" value="false"/>
|
<property name="tests.verbose" value="false"/>
|
||||||
<property name="tests.infostream" value="${tests.verbose}"/>
|
<property name="tests.infostream" value="${tests.verbose}"/>
|
||||||
<property name="tests.filterstacks" value="true"/>
|
<property name="tests.filterstacks" value="true"/>
|
||||||
|
<property name="tests.luceneMatchVersion" value="${version.luceneMatchVersion}"/>
|
||||||
|
|
||||||
<condition property="tests.heapsize" value="768M">
|
<condition property="tests.heapsize" value="768M">
|
||||||
<isset property="run.clover"/>
|
<isset property="run.clover"/>
|
||||||
|
@ -640,7 +666,7 @@
|
||||||
<attribute name="excludes" default="**/pom.xml,**/*.iml"/>
|
<attribute name="excludes" default="**/pom.xml,**/*.iml"/>
|
||||||
<attribute name="metainf.source.dir" default="${common.dir}"/>
|
<attribute name="metainf.source.dir" default="${common.dir}"/>
|
||||||
<attribute name="implementation.title" default="org.apache.lucene"/>
|
<attribute name="implementation.title" default="org.apache.lucene"/>
|
||||||
<attribute name="spec.version" default="${spec.version}"/>
|
<attribute name="spec.version" default="${version}"/>
|
||||||
<attribute name="manifest.file" default="${manifest.file}"/>
|
<attribute name="manifest.file" default="${manifest.file}"/>
|
||||||
<element name="filesets" optional="true"/>
|
<element name="filesets" optional="true"/>
|
||||||
<element name="jarify-additional-manifest-attributes" optional="true"/>
|
<element name="jarify-additional-manifest-attributes" optional="true"/>
|
||||||
|
@ -986,7 +1012,7 @@
|
||||||
<sysproperty key="java.security.manager" value="org.apache.lucene.util.TestSecurityManager" />
|
<sysproperty key="java.security.manager" value="org.apache.lucene.util.TestSecurityManager" />
|
||||||
<sysproperty key="java.security.policy" file="${common.dir}/tools/junit4/tests.policy" />
|
<sysproperty key="java.security.policy" file="${common.dir}/tools/junit4/tests.policy" />
|
||||||
|
|
||||||
<sysproperty key="lucene.version" value="${version}"/>
|
<sysproperty key="tests.LUCENE_VERSION" value="${version.base}"/>
|
||||||
|
|
||||||
<sysproperty key="jetty.testMode" value="1"/>
|
<sysproperty key="jetty.testMode" value="1"/>
|
||||||
<sysproperty key="jetty.insecurerandom" value="1"/>
|
<sysproperty key="jetty.insecurerandom" value="1"/>
|
||||||
|
@ -2468,7 +2494,7 @@ The following arguments can be provided to ant to alter its behaviour and target
|
||||||
|
|
||||||
<junit4:pickseed property="pitest.seed" />
|
<junit4:pickseed property="pitest.seed" />
|
||||||
|
|
||||||
<property name="pitest.sysprops" value="-Dlucene.version=${version},-Dtest.seed=${pitest.seed},-Djava.security.manager=org.apache.lucene.util.TestSecurityManager,-Djava.security.policy=${common.dir}/tools/junit4/tests.policy,-Djava.io.tmpdir=${tests.workDir},-Djunit4.childvm.cwd=${tests.workDir},-Djunit4.tempDir=${tests.workDir}" />
|
<property name="pitest.sysprops" value="-Dversion=${version},-Dtest.seed=${pitest.seed},-Djava.security.manager=org.apache.lucene.util.TestSecurityManager,-Djava.security.policy=${common.dir}/tools/junit4/tests.policy,-Djava.io.tmpdir=${tests.workDir},-Djunit4.childvm.cwd=${tests.workDir},-Djunit4.tempDir=${tests.workDir}" />
|
||||||
|
|
||||||
<pitest
|
<pitest
|
||||||
classPath="pitest.classpath"
|
classPath="pitest.classpath"
|
||||||
|
|
|
@ -72,7 +72,7 @@ import java.util.Map;
|
||||||
public abstract class Analyzer implements Closeable {
|
public abstract class Analyzer implements Closeable {
|
||||||
|
|
||||||
private final ReuseStrategy reuseStrategy;
|
private final ReuseStrategy reuseStrategy;
|
||||||
private Version version = Version.LUCENE_CURRENT;
|
private Version version = Version.LATEST;
|
||||||
|
|
||||||
// non final as it gets nulled if closed; pkg private for access by ReuseStrategy's final helper methods:
|
// non final as it gets nulled if closed; pkg private for access by ReuseStrategy's final helper methods:
|
||||||
CloseableThreadLocal<Object> storedValue = new CloseableThreadLocal<>();
|
CloseableThreadLocal<Object> storedValue = new CloseableThreadLocal<>();
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.IndexInput;
|
import org.apache.lucene.store.IndexInput;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lucene 4.0 implementation of {@link SegmentInfoReader}.
|
* Lucene 4.0 implementation of {@link SegmentInfoReader}.
|
||||||
|
@ -54,7 +55,7 @@ public class Lucene40SegmentInfoReader extends SegmentInfoReader {
|
||||||
CodecUtil.checkHeader(input, Lucene40SegmentInfoFormat.CODEC_NAME,
|
CodecUtil.checkHeader(input, Lucene40SegmentInfoFormat.CODEC_NAME,
|
||||||
Lucene40SegmentInfoFormat.VERSION_START,
|
Lucene40SegmentInfoFormat.VERSION_START,
|
||||||
Lucene40SegmentInfoFormat.VERSION_CURRENT);
|
Lucene40SegmentInfoFormat.VERSION_CURRENT);
|
||||||
final String version = input.readString();
|
final Version version = Version.parse(input.readString());
|
||||||
final int docCount = input.readInt();
|
final int docCount = input.readInt();
|
||||||
if (docCount < 0) {
|
if (docCount < 0) {
|
||||||
throw new CorruptIndexException("invalid docCount: " + docCount + " (resource=" + input + ")");
|
throw new CorruptIndexException("invalid docCount: " + docCount + " (resource=" + input + ")");
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class Lucene40SegmentInfoWriter extends SegmentInfoWriter {
|
||||||
try {
|
try {
|
||||||
CodecUtil.writeHeader(output, Lucene40SegmentInfoFormat.CODEC_NAME, Lucene40SegmentInfoFormat.VERSION_CURRENT);
|
CodecUtil.writeHeader(output, Lucene40SegmentInfoFormat.CODEC_NAME, Lucene40SegmentInfoFormat.VERSION_CURRENT);
|
||||||
// Write the Lucene version that created this segment, since 3.1
|
// Write the Lucene version that created this segment, since 3.1
|
||||||
output.writeString(si.getVersion());
|
output.writeString(si.getVersion().toString());
|
||||||
output.writeInt(si.getDocCount());
|
output.writeInt(si.getDocCount());
|
||||||
|
|
||||||
output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
|
output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
|
||||||
|
|
|
@ -91,8 +91,8 @@ class Lucene45DocValuesProducer extends DocValuesProducer implements Closeable {
|
||||||
/** expert: instantiates a new reader */
|
/** expert: instantiates a new reader */
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
protected Lucene45DocValuesProducer(SegmentReadState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
|
protected Lucene45DocValuesProducer(SegmentReadState state, String dataCodec, String dataExtension, String metaCodec, String metaExtension) throws IOException {
|
||||||
String ver = state.segmentInfo.getVersion();
|
Version ver = state.segmentInfo.getVersion();
|
||||||
lenientFieldInfoCheck = StringHelper.getVersionComparator().compare(ver, "4.9.0") < 0;
|
lenientFieldInfoCheck = Version.LUCENE_4_9_0.onOrAfter(ver);
|
||||||
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
|
String metaName = IndexFileNames.segmentFileName(state.segmentInfo.name, state.segmentSuffix, metaExtension);
|
||||||
// read in the entries from the metadata file.
|
// read in the entries from the metadata file.
|
||||||
ChecksumIndexInput in = state.directory.openChecksumInput(metaName, state.context);
|
ChecksumIndexInput in = state.directory.openChecksumInput(metaName, state.context);
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.store.ChecksumIndexInput;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lucene 4.6 implementation of {@link SegmentInfoReader}.
|
* Lucene 4.6 implementation of {@link SegmentInfoReader}.
|
||||||
|
@ -52,7 +53,7 @@ public class Lucene46SegmentInfoReader extends SegmentInfoReader {
|
||||||
int codecVersion = CodecUtil.checkHeader(input, Lucene46SegmentInfoFormat.CODEC_NAME,
|
int codecVersion = CodecUtil.checkHeader(input, Lucene46SegmentInfoFormat.CODEC_NAME,
|
||||||
Lucene46SegmentInfoFormat.VERSION_START,
|
Lucene46SegmentInfoFormat.VERSION_START,
|
||||||
Lucene46SegmentInfoFormat.VERSION_CURRENT);
|
Lucene46SegmentInfoFormat.VERSION_CURRENT);
|
||||||
final String version = input.readString();
|
final Version version = Version.parse(input.readString());
|
||||||
final int docCount = input.readInt();
|
final int docCount = input.readInt();
|
||||||
if (docCount < 0) {
|
if (docCount < 0) {
|
||||||
throw new CorruptIndexException("invalid docCount: " + docCount + " (resource=" + input + ")");
|
throw new CorruptIndexException("invalid docCount: " + docCount + " (resource=" + input + ")");
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class Lucene46SegmentInfoWriter extends SegmentInfoWriter {
|
||||||
try {
|
try {
|
||||||
CodecUtil.writeHeader(output, Lucene46SegmentInfoFormat.CODEC_NAME, Lucene46SegmentInfoFormat.VERSION_CURRENT);
|
CodecUtil.writeHeader(output, Lucene46SegmentInfoFormat.CODEC_NAME, Lucene46SegmentInfoFormat.VERSION_CURRENT);
|
||||||
// Write the Lucene version that created this segment, since 3.1
|
// Write the Lucene version that created this segment, since 3.1
|
||||||
output.writeString(si.getVersion());
|
output.writeString(si.getVersion().toString());
|
||||||
output.writeInt(si.getDocCount());
|
output.writeInt(si.getDocCount());
|
||||||
|
|
||||||
output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
|
output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
|
||||||
|
|
|
@ -22,7 +22,6 @@ import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -46,7 +45,7 @@ import org.apache.lucene.util.CommandLineUtil;
|
||||||
import org.apache.lucene.util.FixedBitSet;
|
import org.apache.lucene.util.FixedBitSet;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.LongBitSet;
|
import org.apache.lucene.util.LongBitSet;
|
||||||
import org.apache.lucene.util.StringHelper;
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -409,21 +408,19 @@ public class CheckIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find the oldest and newest segment versions
|
// find the oldest and newest segment versions
|
||||||
String oldest = Integer.toString(Integer.MAX_VALUE), newest = Integer.toString(Integer.MIN_VALUE);
|
Version oldest = null;
|
||||||
|
Version newest = null;
|
||||||
String oldSegs = null;
|
String oldSegs = null;
|
||||||
boolean foundNonNullVersion = false;
|
|
||||||
Comparator<String> versionComparator = StringHelper.getVersionComparator();
|
|
||||||
for (SegmentCommitInfo si : sis) {
|
for (SegmentCommitInfo si : sis) {
|
||||||
String version = si.info.getVersion();
|
Version version = si.info.getVersion();
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
// pre-3.1 segment
|
// pre-3.1 segment
|
||||||
oldSegs = "pre-3.1";
|
oldSegs = "pre-3.1";
|
||||||
} else {
|
} else {
|
||||||
foundNonNullVersion = true;
|
if (oldest == null || version.onOrAfter(oldest) == false) {
|
||||||
if (versionComparator.compare(version, oldest) < 0) {
|
|
||||||
oldest = version;
|
oldest = version;
|
||||||
}
|
}
|
||||||
if (versionComparator.compare(version, newest) > 0) {
|
if (newest == null || version.onOrAfter(newest)) {
|
||||||
newest = version;
|
newest = version;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -475,14 +472,14 @@ public class CheckIndex {
|
||||||
userDataString = "";
|
userDataString = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
String versionString = null;
|
String versionString = "";
|
||||||
if (oldSegs != null) {
|
if (oldSegs != null) {
|
||||||
if (foundNonNullVersion) {
|
if (newest != null) {
|
||||||
versionString = "versions=[" + oldSegs + " .. " + newest + "]";
|
versionString = "versions=[" + oldSegs + " .. " + newest + "]";
|
||||||
} else {
|
} else {
|
||||||
versionString = "version=" + oldSegs;
|
versionString = "version=" + oldSegs;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (newest != null) { // implies oldest != null
|
||||||
versionString = oldest.equals(newest) ? ( "version=" + oldest ) : ("versions=[" + oldest + " .. " + newest + "]");
|
versionString = oldest.equals(newest) ? ( "version=" + oldest ) : ("versions=[" + oldest + " .. " + newest + "]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -527,8 +524,8 @@ public class CheckIndex {
|
||||||
segInfoStat.name = info.info.name;
|
segInfoStat.name = info.info.name;
|
||||||
segInfoStat.docCount = info.info.getDocCount();
|
segInfoStat.docCount = info.info.getDocCount();
|
||||||
|
|
||||||
final String version = info.info.getVersion();
|
final Version version = info.info.getVersion();
|
||||||
if (info.info.getDocCount() <= 0 && version != null && versionComparator.compare(version, "4.5") >= 0) {
|
if (info.info.getDocCount() <= 0 && version != null && version.onOrAfter(Version.LUCENE_4_5_0)) {
|
||||||
throw new RuntimeException("illegal number of documents: maxDoc=" + info.info.getDocCount());
|
throw new RuntimeException("illegal number of documents: maxDoc=" + info.info.getDocCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,12 +34,12 @@ import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
||||||
import org.apache.lucene.util.ByteBlockPool.Allocator;
|
import org.apache.lucene.util.ByteBlockPool.Allocator;
|
||||||
import org.apache.lucene.util.ByteBlockPool.DirectTrackingAllocator;
|
import org.apache.lucene.util.ByteBlockPool.DirectTrackingAllocator;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.Counter;
|
import org.apache.lucene.util.Counter;
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.IntBlockPool;
|
import org.apache.lucene.util.IntBlockPool;
|
||||||
import org.apache.lucene.util.MutableBits;
|
import org.apache.lucene.util.MutableBits;
|
||||||
import org.apache.lucene.util.RamUsageEstimator;
|
import org.apache.lucene.util.RamUsageEstimator;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
import static org.apache.lucene.util.ByteBlockPool.BYTE_BLOCK_MASK;
|
import static org.apache.lucene.util.ByteBlockPool.BYTE_BLOCK_MASK;
|
||||||
import static org.apache.lucene.util.ByteBlockPool.BYTE_BLOCK_SIZE;
|
import static org.apache.lucene.util.ByteBlockPool.BYTE_BLOCK_SIZE;
|
||||||
|
@ -178,7 +178,7 @@ class DocumentsWriterPerThread {
|
||||||
pendingUpdates.clear();
|
pendingUpdates.clear();
|
||||||
deleteSlice = deleteQueue.newSlice();
|
deleteSlice = deleteQueue.newSlice();
|
||||||
|
|
||||||
segmentInfo = new SegmentInfo(directoryOrig, Constants.LUCENE_MAIN_VERSION, segmentName, -1, false, codec, null);
|
segmentInfo = new SegmentInfo(directoryOrig, Version.LATEST, segmentName, -1, false, codec, null);
|
||||||
assert numDocsInRAM == 0;
|
assert numDocsInRAM == 0;
|
||||||
if (INFO_VERBOSE && infoStream.isEnabled("DWPT")) {
|
if (INFO_VERBOSE && infoStream.isEnabled("DWPT")) {
|
||||||
infoStream.message("DWPT", Thread.currentThread().getName() + " init seg=" + segmentName + " delQueue=" + deleteQueue);
|
infoStream.message("DWPT", Thread.currentThread().getName() + " init seg=" + segmentName + " delQueue=" + deleteQueue);
|
||||||
|
|
|
@ -20,9 +20,9 @@ package org.apache.lucene.index;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.FSDirectory;
|
import org.apache.lucene.store.FSDirectory;
|
||||||
import org.apache.lucene.util.CommandLineUtil;
|
import org.apache.lucene.util.CommandLineUtil;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.PrintStreamInfoStream;
|
import org.apache.lucene.util.PrintStreamInfoStream;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -160,11 +160,11 @@ public final class IndexUpgrader {
|
||||||
try {
|
try {
|
||||||
InfoStream infoStream = iwc.getInfoStream();
|
InfoStream infoStream = iwc.getInfoStream();
|
||||||
if (infoStream.isEnabled("IndexUpgrader")) {
|
if (infoStream.isEnabled("IndexUpgrader")) {
|
||||||
infoStream.message("IndexUpgrader", "Upgrading all pre-" + Constants.LUCENE_MAIN_VERSION + " segments of index directory '" + dir + "' to version " + Constants.LUCENE_MAIN_VERSION + "...");
|
infoStream.message("IndexUpgrader", "Upgrading all pre-" + Version.LATEST + " segments of index directory '" + dir + "' to version " + Version.LATEST + "...");
|
||||||
}
|
}
|
||||||
w.forceMerge(1);
|
w.forceMerge(1);
|
||||||
if (infoStream.isEnabled("IndexUpgrader")) {
|
if (infoStream.isEnabled("IndexUpgrader")) {
|
||||||
infoStream.message("IndexUpgrader", "All segments upgraded to version " + Constants.LUCENE_MAIN_VERSION);
|
infoStream.message("IndexUpgrader", "All segments upgraded to version " + Version.LATEST);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
w.close();
|
w.close();
|
||||||
|
|
|
@ -64,6 +64,7 @@ import org.apache.lucene.util.Constants;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.ThreadInterruptedException;
|
import org.apache.lucene.util.ThreadInterruptedException;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
An <code>IndexWriter</code> creates and maintains an index.
|
An <code>IndexWriter</code> creates and maintains an index.
|
||||||
|
@ -883,7 +884,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
didMessageState = true;
|
didMessageState = true;
|
||||||
infoStream.message("IW", "\ndir=" + directory + "\n" +
|
infoStream.message("IW", "\ndir=" + directory + "\n" +
|
||||||
"index=" + segString() + "\n" +
|
"index=" + segString() + "\n" +
|
||||||
"version=" + Constants.LUCENE_VERSION + "\n" +
|
"version=" + Version.LATEST.toString() + "\n" +
|
||||||
config.toString());
|
config.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2569,7 +2570,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
// abortable so that IW.close(false) is able to stop it
|
// abortable so that IW.close(false) is able to stop it
|
||||||
TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(directory);
|
TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(directory);
|
||||||
|
|
||||||
SegmentInfo info = new SegmentInfo(directory, Constants.LUCENE_MAIN_VERSION, mergedName, -1,
|
SegmentInfo info = new SegmentInfo(directory, Version.LATEST, mergedName, -1,
|
||||||
false, codec, null);
|
false, codec, null);
|
||||||
|
|
||||||
SegmentMerger merger = new SegmentMerger(mergeReaders, info, infoStream, trackingDir,
|
SegmentMerger merger = new SegmentMerger(mergeReaders, info, infoStream, trackingDir,
|
||||||
|
@ -3793,7 +3794,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
// ConcurrentMergePolicy we keep deterministic segment
|
// ConcurrentMergePolicy we keep deterministic segment
|
||||||
// names.
|
// names.
|
||||||
final String mergeSegmentName = newSegmentName();
|
final String mergeSegmentName = newSegmentName();
|
||||||
SegmentInfo si = new SegmentInfo(directory, Constants.LUCENE_MAIN_VERSION, mergeSegmentName, -1, false, codec, null);
|
SegmentInfo si = new SegmentInfo(directory, Version.LATEST, mergeSegmentName, -1, false, codec, null);
|
||||||
Map<String,String> details = new HashMap<>();
|
Map<String,String> details = new HashMap<>();
|
||||||
details.put("mergeMaxNumSegments", "" + merge.maxNumSegments);
|
details.put("mergeMaxNumSegments", "" + merge.maxNumSegments);
|
||||||
details.put("mergeFactor", Integer.toString(merge.segments.size()));
|
details.put("mergeFactor", Integer.toString(merge.segments.size()));
|
||||||
|
@ -3817,7 +3818,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
private static void setDiagnostics(SegmentInfo info, String source, Map<String,String> details) {
|
private static void setDiagnostics(SegmentInfo info, String source, Map<String,String> details) {
|
||||||
Map<String,String> diagnostics = new HashMap<>();
|
Map<String,String> diagnostics = new HashMap<>();
|
||||||
diagnostics.put("source", source);
|
diagnostics.put("source", source);
|
||||||
diagnostics.put("lucene.version", Constants.LUCENE_VERSION);
|
diagnostics.put("lucene.version", Version.LATEST.toString());
|
||||||
diagnostics.put("os", Constants.OS_NAME);
|
diagnostics.put("os", Constants.OS_NAME);
|
||||||
diagnostics.put("os.arch", Constants.OS_ARCH);
|
diagnostics.put("os.arch", Constants.OS_ARCH);
|
||||||
diagnostics.put("os.version", Constants.OS_VERSION);
|
diagnostics.put("os.version", Constants.OS_VERSION);
|
||||||
|
|
|
@ -27,6 +27,9 @@ import java.util.regex.Matcher;
|
||||||
import org.apache.lucene.codecs.Codec;
|
import org.apache.lucene.codecs.Codec;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
||||||
|
import org.apache.lucene.util.Constants;
|
||||||
|
import org.apache.lucene.util.StringHelper;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Information about a segment such as it's name, directory, and files related
|
* Information about a segment such as it's name, directory, and files related
|
||||||
|
@ -62,9 +65,9 @@ public final class SegmentInfo {
|
||||||
// Tracks the Lucene version this segment was created with, since 3.1. Null
|
// Tracks the Lucene version this segment was created with, since 3.1. Null
|
||||||
// indicates an older than 3.0 index, and it's used to detect a too old index.
|
// indicates an older than 3.0 index, and it's used to detect a too old index.
|
||||||
// The format expected is "x.y" - "2.x" for pre-3.0 indexes (or null), and
|
// The format expected is "x.y" - "2.x" for pre-3.0 indexes (or null), and
|
||||||
// specific versions afterwards ("3.0", "3.1" etc.).
|
// specific versions afterwards ("3.0.0", "3.1.0" etc.).
|
||||||
// see Constants.LUCENE_MAIN_VERSION.
|
// see o.a.l.util.Version.
|
||||||
private String version;
|
private Version version;
|
||||||
|
|
||||||
void setDiagnostics(Map<String, String> diagnostics) {
|
void setDiagnostics(Map<String, String> diagnostics) {
|
||||||
this.diagnostics = diagnostics;
|
this.diagnostics = diagnostics;
|
||||||
|
@ -81,7 +84,7 @@ public final class SegmentInfo {
|
||||||
* <p>Note: this is public only to allow access from
|
* <p>Note: this is public only to allow access from
|
||||||
* the codecs package.</p>
|
* the codecs package.</p>
|
||||||
*/
|
*/
|
||||||
public SegmentInfo(Directory dir, String version, String name, int docCount,
|
public SegmentInfo(Directory dir, Version version, String name, int docCount,
|
||||||
boolean isCompoundFile, Codec codec, Map<String,String> diagnostics) {
|
boolean isCompoundFile, Codec codec, Map<String,String> diagnostics) {
|
||||||
assert !(dir instanceof TrackingDirectoryWrapper);
|
assert !(dir instanceof TrackingDirectoryWrapper);
|
||||||
this.dir = dir;
|
this.dir = dir;
|
||||||
|
@ -203,23 +206,9 @@ public final class SegmentInfo {
|
||||||
return dir.hashCode() + name.hashCode();
|
return dir.hashCode() + name.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Returns the version of the code which wrote the segment.
|
||||||
* Used by DefaultSegmentInfosReader to upgrade a 3.0 segment to record its
|
|
||||||
* version is "3.0". This method can be removed when we're not required to
|
|
||||||
* support 3x indexes anymore, e.g. in 5.0.
|
|
||||||
* <p>
|
|
||||||
* <b>NOTE:</b> this method is used for internal purposes only - you should
|
|
||||||
* not modify the version of a SegmentInfo, or it may result in unexpected
|
|
||||||
* exceptions thrown when you attempt to open the index.
|
|
||||||
*
|
|
||||||
* @lucene.internal
|
|
||||||
*/
|
*/
|
||||||
public void setVersion(String version) {
|
public Version getVersion() {
|
||||||
this.version = version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the version of the code which wrote the segment. */
|
|
||||||
public String getVersion() {
|
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -200,8 +200,8 @@ public final class SegmentReader extends AtomicReader implements Accountable {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ver = si.info.getVersion();
|
Version ver = si.info.getVersion();
|
||||||
if (ver != null && StringHelper.getVersionComparator().compare(ver, "4.9.0") >= 0) {
|
if (ver != null && ver.onOrAfter(Version.LUCENE_4_9_0)) {
|
||||||
DocValuesProducer baseProducer = null;
|
DocValuesProducer baseProducer = null;
|
||||||
for (FieldInfo fi : fieldInfos) {
|
for (FieldInfo fi : fieldInfos) {
|
||||||
if (!fi.hasDocValues()) continue;
|
if (!fi.hasDocValues()) continue;
|
||||||
|
|
|
@ -17,7 +17,7 @@ package org.apache.lucene.index;
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.lucene.util.Constants;
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -60,12 +60,12 @@ public class UpgradeIndexMergePolicy extends MergePolicy {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns if the given segment should be upgraded. The default implementation
|
/** Returns if the given segment should be upgraded. The default implementation
|
||||||
* will return {@code !Constants.LUCENE_MAIN_VERSION.equals(si.getVersion())},
|
* will return {@code !Version.LATEST.equals(si.getVersion())},
|
||||||
* so all segments created with a different version number than this Lucene version will
|
* so all segments created with a different version number than this Lucene version will
|
||||||
* get upgraded.
|
* get upgraded.
|
||||||
*/
|
*/
|
||||||
protected boolean shouldUpgradeSegment(SegmentCommitInfo si) {
|
protected boolean shouldUpgradeSegment(SegmentCommitInfo si) {
|
||||||
return !Constants.LUCENE_MAIN_VERSION.equals(si.info.getVersion());
|
return !Version.LATEST.equals(si.info.getVersion());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -52,7 +52,7 @@ import org.apache.lucene.util.IOUtils;
|
||||||
* <pre class="prettyprint">
|
* <pre class="prettyprint">
|
||||||
* Directory fsDir = FSDirectory.open(new File("/path/to/index"));
|
* Directory fsDir = FSDirectory.open(new File("/path/to/index"));
|
||||||
* NRTCachingDirectory cachedFSDir = new NRTCachingDirectory(fsDir, 5.0, 60.0);
|
* NRTCachingDirectory cachedFSDir = new NRTCachingDirectory(fsDir, 5.0, 60.0);
|
||||||
* IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_5_0, analyzer);
|
* IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_5_0_0, analyzer);
|
||||||
* IndexWriter writer = new IndexWriter(cachedFSDir, conf);
|
* IndexWriter writer = new IndexWriter(cachedFSDir, conf);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.lucene.util;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import org.apache.lucene.LucenePackage;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some useful constants.
|
* Some useful constants.
|
||||||
|
@ -93,45 +92,18 @@ public final class Constants {
|
||||||
JRE_IS_MINIMUM_JAVA8 = v8;
|
JRE_IS_MINIMUM_JAVA8 = v8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this method prevents inlining the final version constant in compiled classes,
|
|
||||||
// see: http://www.javaworld.com/community/node/3400
|
|
||||||
private static String ident(final String s) {
|
|
||||||
return s.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
// We should never change index format with minor versions, so it should always be x.y or x.y.0.z for alpha/beta versions!
|
|
||||||
/**
|
/**
|
||||||
* This is the internal Lucene version, recorded into each segment.
|
* This is the internal Lucene version, including bugfix versions, recorded into each segment.
|
||||||
* NOTE: we track per-segment version as a String with the {@code "X.Y"} format
|
* @deprecated Use {@link Version#LATEST}
|
||||||
* (no minor version), e.g. {@code "4.0", "3.1", "3.0"}.
|
|
||||||
* <p>Alpha and Beta versions will have numbers like {@code "X.Y.0.Z"},
|
|
||||||
* anything else is not allowed. This is done to prevent people from
|
|
||||||
* using indexes created with ALPHA/BETA versions with the released version.
|
|
||||||
*/
|
*/
|
||||||
public static final String LUCENE_MAIN_VERSION = ident("5.0");
|
@Deprecated
|
||||||
|
public static final String LUCENE_MAIN_VERSION = Version.LATEST.toString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the Lucene version for display purposes.
|
* Don't use this constant because the name is not self-describing!
|
||||||
|
* @deprecated Use {@link Version#LATEST}
|
||||||
*/
|
*/
|
||||||
public static final String LUCENE_VERSION;
|
@Deprecated
|
||||||
static {
|
public static final String LUCENE_VERSION = Version.LATEST.toString();
|
||||||
Package pkg = LucenePackage.get();
|
|
||||||
String v = (pkg == null) ? null : pkg.getImplementationVersion();
|
|
||||||
if (v == null) {
|
|
||||||
v = mainVersionWithoutAlphaBeta() + "-SNAPSHOT";
|
|
||||||
}
|
|
||||||
LUCENE_VERSION = ident(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a LUCENE_MAIN_VERSION without any ALPHA/BETA qualifier
|
|
||||||
* Used by test only!
|
|
||||||
*/
|
|
||||||
static String mainVersionWithoutAlphaBeta() {
|
|
||||||
final String parts[] = LUCENE_MAIN_VERSION.split("\\.");
|
|
||||||
if (parts.length == 4 && "0".equals(parts[2])) {
|
|
||||||
return parts[0] + "." + parts[1];
|
|
||||||
}
|
|
||||||
return LUCENE_MAIN_VERSION;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,45 +67,6 @@ public abstract class StringHelper {
|
||||||
private StringHelper() {
|
private StringHelper() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a Comparator over versioned strings such as X.YY.Z
|
|
||||||
* @lucene.internal
|
|
||||||
*/
|
|
||||||
public static Comparator<String> getVersionComparator() {
|
|
||||||
return versionComparator;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Comparator<String> versionComparator = new Comparator<String>() {
|
|
||||||
@Override
|
|
||||||
public int compare(String a, String b) {
|
|
||||||
StringTokenizer aTokens = new StringTokenizer(a, ".");
|
|
||||||
StringTokenizer bTokens = new StringTokenizer(b, ".");
|
|
||||||
|
|
||||||
while (aTokens.hasMoreTokens()) {
|
|
||||||
int aToken = Integer.parseInt(aTokens.nextToken());
|
|
||||||
if (bTokens.hasMoreTokens()) {
|
|
||||||
int bToken = Integer.parseInt(bTokens.nextToken());
|
|
||||||
if (aToken != bToken) {
|
|
||||||
return aToken < bToken ? -1 : 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// a has some extra trailing tokens. if these are all zeroes, thats ok.
|
|
||||||
if (aToken != 0) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// b has some extra trailing tokens. if these are all zeroes, thats ok.
|
|
||||||
while (bTokens.hasMoreTokens()) {
|
|
||||||
if (Integer.parseInt(bTokens.nextToken()) != 0)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public static boolean equals(String s1, String s2) {
|
public static boolean equals(String s1, String s2) {
|
||||||
if (s1 == null) {
|
if (s1 == null) {
|
||||||
return s2 == null;
|
return s2 == null;
|
||||||
|
|
|
@ -29,95 +29,158 @@ import java.util.Locale;
|
||||||
* change the version at search-time, but instead also adjust
|
* change the version at search-time, but instead also adjust
|
||||||
* your indexing code to match, and re-index.
|
* your indexing code to match, and re-index.
|
||||||
*/
|
*/
|
||||||
// remove me when java 5 is no longer supported
|
public final class Version {
|
||||||
// this is a workaround for a JDK bug that wrongly emits a warning.
|
|
||||||
@SuppressWarnings("dep-ann")
|
|
||||||
public enum Version {
|
|
||||||
/**
|
|
||||||
* Match settings and bugs in Lucene's 4.0 release.
|
|
||||||
* @deprecated (5.0) Use latest
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
LUCENE_4_0,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.1 release.
|
* Match settings and bugs in Lucene's 4.0.0-ALPHA release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_1,
|
public static final Version LUCENE_4_0_0_ALPHA = new Version(4, 0, 0, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.2 release.
|
* Match settings and bugs in Lucene's 4.0.0-BETA release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_2,
|
public static final Version LUCENE_4_0_0_BETA = new Version(4, 0, 0, 2);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.3 release.
|
* Match settings and bugs in Lucene's 4.0.0 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_3,
|
public static final Version LUCENE_4_0_0 = new Version(4, 0, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.4 release.
|
* Match settings and bugs in Lucene's 4.1.0 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_4,
|
public static final Version LUCENE_4_1_0 = new Version(4, 1, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.5 release.
|
* Match settings and bugs in Lucene's 4.2.0 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_5,
|
public static final Version LUCENE_4_2_0 = new Version(4, 2, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.6 release.
|
* Match settings and bugs in Lucene's 4.2.1 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_6,
|
public static final Version LUCENE_4_2_1 = new Version(4, 2, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.7 release.
|
* Match settings and bugs in Lucene's 4.3.0 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_7,
|
public static final Version LUCENE_4_3_0 = new Version(4, 3, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.8 release.
|
* Match settings and bugs in Lucene's 4.3.1 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_8,
|
public static final Version LUCENE_4_3_1 = new Version(4, 3, 1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.9 release.
|
* Match settings and bugs in Lucene's 4.4.0 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_9,
|
public static final Version LUCENE_4_4_0 = new Version(4, 4, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.5.0 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_5_0 = new Version(4, 5, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.5.1 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_5_1 = new Version(4, 5, 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.6.0 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_6_0 = new Version(4, 6, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.6.1 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_6_1 = new Version(4, 6, 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.7.0 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_7_0 = new Version(4, 7, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.7.1 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_7_1 = new Version(4, 7, 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.7.2 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_7_2 = new Version(4, 7, 2);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.8.0 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_8_0 = new Version(4, 8, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.8.1 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_8_1 = new Version(4, 8, 1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Match settings and bugs in Lucene's 4.9.0 release.
|
||||||
|
* @deprecated (5.0) Use latest
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_9_0 = new Version(4, 9, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.10 release.
|
* Match settings and bugs in Lucene's 4.10 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_4_10,
|
public static final Version LUCENE_4_10_0 = new Version(4, 10, 0);
|
||||||
|
|
||||||
/** Match settings and bugs in Lucene's 5.0 release.
|
/** Match settings and bugs in Lucene's 5.0 release.
|
||||||
* <p>
|
* <p>
|
||||||
* Use this to get the latest & greatest settings, bug
|
* Use this to get the latest & greatest settings, bug
|
||||||
* fixes, etc, for Lucene.
|
* fixes, etc, for Lucene.
|
||||||
*/
|
*/
|
||||||
LUCENE_5_0,
|
public static final Version LUCENE_5_0_0 = new Version(5, 0, 0);
|
||||||
|
|
||||||
/* Add new constants for later versions **here** to respect order! */
|
// To add a new version:
|
||||||
|
// * Only add above this comment
|
||||||
|
// * If the new version is the newest, change LATEST below and deprecate the previous LATEST
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p><b>WARNING</b>: if you use this setting, and then
|
* <p><b>WARNING</b>: if you use this setting, and then
|
||||||
|
@ -133,20 +196,157 @@ public enum Version {
|
||||||
* application</b> to ensure it behaves as expected, as
|
* application</b> to ensure it behaves as expected, as
|
||||||
* some defaults may have changed and may break functionality
|
* some defaults may have changed and may break functionality
|
||||||
* in your application.
|
* in your application.
|
||||||
* @deprecated Use an actual version instead.
|
*/
|
||||||
|
public static final Version LATEST = LUCENE_5_0_0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constant for backwards compatibility.
|
||||||
|
* @deprecated Use {@link #LATEST}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_CURRENT;
|
public static final Version LUCENE_CURRENT = LATEST;
|
||||||
|
|
||||||
public boolean onOrAfter(Version other) {
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_0_0} instead. */
|
||||||
return compareTo(other) >= 0;
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_0 = LUCENE_4_0_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_1_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_1 = LUCENE_4_1_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_2_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_2 = LUCENE_4_2_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_3_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_3 = LUCENE_4_3_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_4_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_4 = LUCENE_4_4_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_5_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_5 = LUCENE_4_5_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_6_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_6 = LUCENE_4_6_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_7_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_7 = LUCENE_4_7_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_8_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_8 = LUCENE_4_8_0;
|
||||||
|
|
||||||
|
/** @deprecated Bad naming of constant; use {@link #LUCENE_4_9_0} instead. */
|
||||||
|
@Deprecated
|
||||||
|
public static final Version LUCENE_4_9 = LUCENE_4_9_0;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a version number of the form {@code "major.minor.bugfix.prerelease"}.
|
||||||
|
*
|
||||||
|
* Part {@code ".bugfix"} and part {@code ".prerelease"} are optional.
|
||||||
|
* Note that this is forwards compatible: the parsed version does not have to exist as
|
||||||
|
* a constant.
|
||||||
|
*/
|
||||||
|
public static Version parse(String version) {
|
||||||
|
String[] pieces = version.split("\\.");
|
||||||
|
if (pieces.length < 2 || pieces.length > 4) {
|
||||||
|
throw new IllegalArgumentException("Version is not in form major.minor.bugfix(.prerelease): " + version);
|
||||||
|
}
|
||||||
|
|
||||||
|
int major = Integer.parseInt(pieces[0]);
|
||||||
|
int minor = Integer.parseInt(pieces[1]);
|
||||||
|
int bugfix = 0;
|
||||||
|
int prerelease = 0;
|
||||||
|
if (pieces.length > 2) {
|
||||||
|
bugfix = Integer.parseInt(pieces[2]);
|
||||||
|
}
|
||||||
|
if (pieces.length > 3) {
|
||||||
|
prerelease = Integer.parseInt(pieces[3]);
|
||||||
|
if (prerelease == 0) {
|
||||||
|
throw new IllegalArgumentException("Invalid value " + prerelease + " for prelrease of version " + version +", should be 1 or 2");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Version(major, minor, bugfix, prerelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse the given version number as a constant or dot based version.
|
||||||
|
* <p>This method allows to use {@code "LUCENE_X_Y"} constant names,
|
||||||
|
* or version numbers in the format {@code "x.y.z"}.
|
||||||
|
*/
|
||||||
public static Version parseLeniently(String version) {
|
public static Version parseLeniently(String version) {
|
||||||
|
if (version.equals("LATEST") || version.equals("LUCENE_CURRENT")) return LATEST;
|
||||||
final String parsedMatchVersion = version
|
final String parsedMatchVersion = version
|
||||||
.toUpperCase(Locale.ROOT)
|
.toUpperCase(Locale.ROOT)
|
||||||
.replaceFirst("^(\\d+)\\.(\\d+)$", "LUCENE_$1_$2")
|
.replaceFirst("^LUCENE_(\\d+)_(\\d+)_(\\d+)$", "$1.$2.$3")
|
||||||
.replaceFirst("^LUCENE_(\\d)(\\d)$", "LUCENE_$1_$2");
|
.replaceFirst("^LUCENE_(\\d+)_(\\d+)$", "$1.$2.0")
|
||||||
return Version.valueOf(parsedMatchVersion);
|
.replaceFirst("^LUCENE_(\\d)(\\d)$", "$1.$2.0");
|
||||||
|
return parse(parsedMatchVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
// stores the version pieces, with most significant pieces in high bits
|
||||||
|
// ie: | 1 byte | 1 byte | 1 byte | 2 bits |
|
||||||
|
// major minor bugfix prerelease
|
||||||
|
private final int encodedValue;
|
||||||
|
|
||||||
|
private Version(int major, int minor, int bugfix) {
|
||||||
|
this(major, minor, bugfix, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Version(int major, int minor, int bugfix, int prerelease) {
|
||||||
|
if (major > 5 || major < 4) {
|
||||||
|
throw new IllegalArgumentException("Lucene 5.x only supports 5.x and 4.x versions");
|
||||||
|
}
|
||||||
|
if (minor > 255 | minor < 0) {
|
||||||
|
throw new IllegalArgumentException("Illegal minor version: " + minor);
|
||||||
|
}
|
||||||
|
if (bugfix > 255 | bugfix < 0) {
|
||||||
|
throw new IllegalArgumentException("Illegal bugfix version: " + bugfix);
|
||||||
|
}
|
||||||
|
if (prerelease > 2 | prerelease < 0) {
|
||||||
|
throw new IllegalArgumentException("Illegal prerelease version: " + prerelease);
|
||||||
|
}
|
||||||
|
if (prerelease != 0 && (minor != 0 || bugfix != 0)) {
|
||||||
|
throw new IllegalArgumentException("Prerelease version only supported with major release");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prerelease == 0) {
|
||||||
|
// final release should sort after alpha/beta
|
||||||
|
prerelease = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
encodedValue = major << 18 | minor << 10 | bugfix << 2 | prerelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this version is the same or after the version from the argument.
|
||||||
|
*/
|
||||||
|
public boolean onOrAfter(Version other) {
|
||||||
|
return encodedValue >= other.encodedValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
int major = (encodedValue >>> 18) & 0xFF;
|
||||||
|
int minor = (encodedValue >>> 10) & 0xFF;
|
||||||
|
int bugfix = (encodedValue >>> 2) & 0xFF;
|
||||||
|
int prerelease = encodedValue & 0x3;
|
||||||
|
if (prerelease == 3) { // ie unencoded value is 0
|
||||||
|
return "" + major + "." + minor + "." + bugfix;
|
||||||
|
}
|
||||||
|
return "" + major + "." + minor + "." + bugfix + "." + prerelease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
return o != null && o instanceof Version && ((Version)o).encodedValue == encodedValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@ import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -59,14 +58,13 @@ import org.apache.lucene.store.RAMDirectory;
|
||||||
import org.apache.lucene.store.SimpleFSDirectory;
|
import org.apache.lucene.store.SimpleFSDirectory;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||||
import org.apache.lucene.util.NumericUtils;
|
import org.apache.lucene.util.NumericUtils;
|
||||||
import org.apache.lucene.util.StringHelper;
|
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
@ -846,23 +844,21 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
riw.close();
|
riw.close();
|
||||||
DirectoryReader ir = DirectoryReader.open(currentDir);
|
DirectoryReader ir = DirectoryReader.open(currentDir);
|
||||||
SegmentReader air = (SegmentReader)ir.leaves().get(0).reader();
|
SegmentReader air = (SegmentReader)ir.leaves().get(0).reader();
|
||||||
String currentVersion = air.getSegmentInfo().info.getVersion();
|
Version currentVersion = air.getSegmentInfo().info.getVersion();
|
||||||
assertNotNull(currentVersion); // only 3.0 segments can have a null version
|
assertNotNull(currentVersion); // only 3.0 segments can have a null version
|
||||||
ir.close();
|
ir.close();
|
||||||
currentDir.close();
|
currentDir.close();
|
||||||
|
|
||||||
Comparator<String> comparator = StringHelper.getVersionComparator();
|
|
||||||
|
|
||||||
// now check all the old indexes, their version should be < the current version
|
// now check all the old indexes, their version should be < the current version
|
||||||
for (String name : oldNames) {
|
for (String name : oldNames) {
|
||||||
Directory dir = oldIndexDirs.get(name);
|
Directory dir = oldIndexDirs.get(name);
|
||||||
DirectoryReader r = DirectoryReader.open(dir);
|
DirectoryReader r = DirectoryReader.open(dir);
|
||||||
for (AtomicReaderContext context : r.leaves()) {
|
for (AtomicReaderContext context : r.leaves()) {
|
||||||
air = (SegmentReader) context.reader();
|
air = (SegmentReader) context.reader();
|
||||||
String oldVersion = air.getSegmentInfo().info.getVersion();
|
Version oldVersion = air.getSegmentInfo().info.getVersion();
|
||||||
assertNotNull(oldVersion); // only 3.0 segments can have a null version
|
assertNotNull(oldVersion); // only 3.0 segments can have a null version
|
||||||
assertTrue("current Constants.LUCENE_MAIN_VERSION is <= an old index: did you forget to bump it?!",
|
assertTrue("current Version.LATEST is <= an old index: did you forget to bump it?!",
|
||||||
comparator.compare(oldVersion, currentVersion) < 0);
|
currentVersion.onOrAfter(oldVersion));
|
||||||
}
|
}
|
||||||
r.close();
|
r.close();
|
||||||
}
|
}
|
||||||
|
@ -920,7 +916,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
|
||||||
System.out.println("checkAllSegmentsUpgraded: " + infos);
|
System.out.println("checkAllSegmentsUpgraded: " + infos);
|
||||||
}
|
}
|
||||||
for (SegmentCommitInfo si : infos) {
|
for (SegmentCommitInfo si : infos) {
|
||||||
assertEquals(Constants.LUCENE_MAIN_VERSION, si.info.getVersion());
|
assertEquals(Version.LATEST, si.info.getVersion());
|
||||||
}
|
}
|
||||||
return infos.size();
|
return infos.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ import org.apache.lucene.search.ScoreDoc;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
// TODO: test multiple codecs here?
|
// TODO: test multiple codecs here?
|
||||||
|
@ -252,7 +252,7 @@ public class TestCodecs extends LuceneTestCase {
|
||||||
final Directory dir = newDirectory();
|
final Directory dir = newDirectory();
|
||||||
this.write(fieldInfos, dir, fields);
|
this.write(fieldInfos, dir, fields);
|
||||||
Codec codec = Codec.getDefault();
|
Codec codec = Codec.getDefault();
|
||||||
final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
|
final SegmentInfo si = new SegmentInfo(dir, Version.LATEST, SEGMENT, 10000, false, codec, null);
|
||||||
|
|
||||||
final FieldsProducer reader = codec.postingsFormat().fieldsProducer(new SegmentReadState(dir, si, fieldInfos, newIOContext(random())));
|
final FieldsProducer reader = codec.postingsFormat().fieldsProducer(new SegmentReadState(dir, si, fieldInfos, newIOContext(random())));
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ public class TestCodecs extends LuceneTestCase {
|
||||||
|
|
||||||
this.write(fieldInfos, dir, fields);
|
this.write(fieldInfos, dir, fields);
|
||||||
Codec codec = Codec.getDefault();
|
Codec codec = Codec.getDefault();
|
||||||
final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
|
final SegmentInfo si = new SegmentInfo(dir, Version.LATEST, SEGMENT, 10000, false, codec, null);
|
||||||
|
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
System.out.println("TEST: now read postings");
|
System.out.println("TEST: now read postings");
|
||||||
|
@ -804,7 +804,7 @@ public class TestCodecs extends LuceneTestCase {
|
||||||
private void write(final FieldInfos fieldInfos, final Directory dir, final FieldData[] fields) throws Throwable {
|
private void write(final FieldInfos fieldInfos, final Directory dir, final FieldData[] fields) throws Throwable {
|
||||||
|
|
||||||
final Codec codec = Codec.getDefault();
|
final Codec codec = Codec.getDefault();
|
||||||
final SegmentInfo si = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, SEGMENT, 10000, false, codec, null);
|
final SegmentInfo si = new SegmentInfo(dir, Version.LATEST, SEGMENT, 10000, false, codec, null);
|
||||||
final SegmentWriteState state = new SegmentWriteState(InfoStream.getDefault(), dir, si, fieldInfos, null, newIOContext(random()));
|
final SegmentWriteState state = new SegmentWriteState(InfoStream.getDefault(), dir, si, fieldInfos, null, newIOContext(random()));
|
||||||
|
|
||||||
Arrays.sort(fields);
|
Arrays.sort(fields);
|
||||||
|
|
|
@ -41,9 +41,9 @@ import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
import org.apache.lucene.store.TrackingDirectoryWrapper;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
|
|
||||||
/** JUnit adaptation of an older test case DocTest. */
|
/** JUnit adaptation of an older test case DocTest. */
|
||||||
|
@ -217,7 +217,7 @@ public class TestDoc extends LuceneTestCase {
|
||||||
|
|
||||||
final Codec codec = Codec.getDefault();
|
final Codec codec = Codec.getDefault();
|
||||||
TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(si1.info.dir);
|
TrackingDirectoryWrapper trackingDir = new TrackingDirectoryWrapper(si1.info.dir);
|
||||||
final SegmentInfo si = new SegmentInfo(si1.info.dir, Constants.LUCENE_MAIN_VERSION, merged, -1, false, codec, null);
|
final SegmentInfo si = new SegmentInfo(si1.info.dir, Version.LATEST, merged, -1, false, codec, null);
|
||||||
|
|
||||||
SegmentMerger merger = new SegmentMerger(Arrays.<AtomicReader>asList(r1, r2),
|
SegmentMerger merger = new SegmentMerger(Arrays.<AtomicReader>asList(r1, r2),
|
||||||
si, InfoStream.getDefault(), trackingDir,
|
si, InfoStream.getDefault(), trackingDir,
|
||||||
|
@ -226,7 +226,7 @@ public class TestDoc extends LuceneTestCase {
|
||||||
MergeState mergeState = merger.merge();
|
MergeState mergeState = merger.merge();
|
||||||
r1.close();
|
r1.close();
|
||||||
r2.close();
|
r2.close();
|
||||||
final SegmentInfo info = new SegmentInfo(si1.info.dir, Constants.LUCENE_MAIN_VERSION, merged,
|
final SegmentInfo info = new SegmentInfo(si1.info.dir, Version.LATEST, merged,
|
||||||
si1.info.getDocCount() + si2.info.getDocCount(),
|
si1.info.getDocCount() + si2.info.getDocCount(),
|
||||||
false, codec, null);
|
false, codec, null);
|
||||||
info.setFiles(new HashSet<>(trackingDir.getCreatedFiles()));
|
info.setFiles(new HashSet<>(trackingDir.getCreatedFiles()));
|
||||||
|
|
|
@ -25,11 +25,11 @@ import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.search.DocIdSetIterator;
|
import org.apache.lucene.search.DocIdSetIterator;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.FixedBitSet;
|
import org.apache.lucene.util.FixedBitSet;
|
||||||
import org.apache.lucene.util.InfoStream;
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
|
|
||||||
public class TestSegmentMerger extends LuceneTestCase {
|
public class TestSegmentMerger extends LuceneTestCase {
|
||||||
//The variables for the new merged segment
|
//The variables for the new merged segment
|
||||||
|
@ -78,7 +78,7 @@ public class TestSegmentMerger extends LuceneTestCase {
|
||||||
|
|
||||||
public void testMerge() throws IOException {
|
public void testMerge() throws IOException {
|
||||||
final Codec codec = Codec.getDefault();
|
final Codec codec = Codec.getDefault();
|
||||||
final SegmentInfo si = new SegmentInfo(mergedDir, Constants.LUCENE_MAIN_VERSION, mergedSegment, -1, false, codec, null);
|
final SegmentInfo si = new SegmentInfo(mergedDir, Version.LATEST, mergedSegment, -1, false, codec, null);
|
||||||
|
|
||||||
SegmentMerger merger = new SegmentMerger(Arrays.<AtomicReader>asList(reader1, reader2),
|
SegmentMerger merger = new SegmentMerger(Arrays.<AtomicReader>asList(reader1, reader2),
|
||||||
si, InfoStream.getDefault(), mergedDir,
|
si, InfoStream.getDefault(), mergedDir,
|
||||||
|
@ -88,7 +88,7 @@ public class TestSegmentMerger extends LuceneTestCase {
|
||||||
assertTrue(docsMerged == 2);
|
assertTrue(docsMerged == 2);
|
||||||
//Should be able to open a new SegmentReader against the new directory
|
//Should be able to open a new SegmentReader against the new directory
|
||||||
SegmentReader mergedReader = new SegmentReader(new SegmentCommitInfo(
|
SegmentReader mergedReader = new SegmentReader(new SegmentCommitInfo(
|
||||||
new SegmentInfo(mergedDir, Constants.LUCENE_MAIN_VERSION, mergedSegment, docsMerged,
|
new SegmentInfo(mergedDir, Version.LATEST, mergedSegment, docsMerged,
|
||||||
false, codec, null),
|
false, codec, null),
|
||||||
0, -1L, -1L, -1L),
|
0, -1L, -1L, -1L),
|
||||||
newIOContext(random()));
|
newIOContext(random()));
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
package org.apache.lucene.util;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class TestConstants extends LuceneTestCase {
|
|
||||||
|
|
||||||
private String getVersionDetails() {
|
|
||||||
return " (LUCENE_MAIN_VERSION=" + Constants.LUCENE_MAIN_VERSION +
|
|
||||||
", LUCENE_MAIN_VERSION(without alpha/beta)=" + Constants.mainVersionWithoutAlphaBeta() +
|
|
||||||
", LUCENE_VERSION=" + Constants.LUCENE_VERSION + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testLuceneMainVersionConstant() {
|
|
||||||
assertTrue("LUCENE_MAIN_VERSION does not follow pattern: 'x.y' (stable release) or 'x.y.0.z' (alpha/beta version)" + getVersionDetails(),
|
|
||||||
Constants.LUCENE_MAIN_VERSION.matches("\\d+\\.\\d+(|\\.0\\.\\d+)"));
|
|
||||||
assertTrue("LUCENE_VERSION does not start with LUCENE_MAIN_VERSION (without alpha/beta marker)" + getVersionDetails(),
|
|
||||||
Constants.LUCENE_VERSION.startsWith(Constants.mainVersionWithoutAlphaBeta()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBuildSetup() {
|
|
||||||
// common-build.xml sets lucene.version, if not, we skip this test!
|
|
||||||
String version = System.getProperty("lucene.version");
|
|
||||||
assumeTrue("Null lucene.version test property. You should run the tests with the official Lucene build file",
|
|
||||||
version != null);
|
|
||||||
|
|
||||||
// remove anything after a "-" from the version string:
|
|
||||||
version = version.replaceAll("-.*$", "");
|
|
||||||
String versionConstant = Constants.LUCENE_VERSION.replaceAll("-.*$", "");
|
|
||||||
assertTrue("LUCENE_VERSION should share the same prefix with lucene.version test property ('" + version + "')." + getVersionDetails(),
|
|
||||||
versionConstant.startsWith(version) || version.startsWith(versionConstant));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -17,46 +17,173 @@
|
||||||
|
|
||||||
package org.apache.lucene.util;
|
package org.apache.lucene.util;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
|
||||||
public class TestVersion extends LuceneTestCase {
|
public class TestVersion extends LuceneTestCase {
|
||||||
|
|
||||||
public void test() {
|
public void testOnOrAfter() throws Exception {
|
||||||
for (Version v : Version.values()) {
|
for (Field field : Version.class.getDeclaredFields()) {
|
||||||
assertTrue("LUCENE_CURRENT must be always onOrAfter("+v+")", Version.LUCENE_CURRENT.onOrAfter(v));
|
if (Modifier.isStatic(field.getModifiers()) && field.getType() == Version.class) {
|
||||||
|
Version v = (Version)field.get(Version.class);
|
||||||
|
assertTrue("LATEST must be always onOrAfter("+v+")", Version.LATEST.onOrAfter(v));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
assertTrue(Version.LUCENE_5_0.onOrAfter(Version.LUCENE_4_0));
|
assertTrue(Version.LUCENE_5_0_0.onOrAfter(Version.LUCENE_4_0_0));
|
||||||
assertFalse(Version.LUCENE_4_0.onOrAfter(Version.LUCENE_5_0));
|
assertFalse(Version.LUCENE_4_0_0.onOrAfter(Version.LUCENE_5_0_0));
|
||||||
|
assertTrue(Version.LUCENE_4_0_0_ALPHA.onOrAfter(Version.LUCENE_4_0_0_ALPHA));
|
||||||
|
assertTrue(Version.LUCENE_4_0_0_BETA.onOrAfter(Version.LUCENE_4_0_0_ALPHA));
|
||||||
|
assertTrue(Version.LUCENE_4_0_0.onOrAfter(Version.LUCENE_4_0_0_ALPHA));
|
||||||
|
assertTrue(Version.LUCENE_4_0_0.onOrAfter(Version.LUCENE_4_0_0_BETA));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testToString() {
|
||||||
|
assertEquals("4.2.0", Version.LUCENE_4_2_0.toString());
|
||||||
|
assertEquals("4.2.0", Version.LUCENE_4_2.toString());
|
||||||
|
assertEquals("4.2.1", Version.LUCENE_4_2_1.toString());
|
||||||
|
assertEquals("4.0.0.1", Version.LUCENE_4_0_0_ALPHA.toString());
|
||||||
|
assertEquals("4.0.0.2", Version.LUCENE_4_0_0_BETA.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseLeniently() {
|
public void testParseLeniently() {
|
||||||
assertEquals(Version.LUCENE_4_0, Version.parseLeniently("4.0"));
|
assertEquals(Version.LUCENE_4_0_0, Version.parseLeniently("4.0"));
|
||||||
assertEquals(Version.LUCENE_4_0, Version.parseLeniently("LUCENE_40"));
|
assertEquals(Version.LUCENE_4_0_0, Version.parseLeniently("4.0.0"));
|
||||||
assertEquals(Version.LUCENE_4_0, Version.parseLeniently("LUCENE_4_0"));
|
assertEquals(Version.LUCENE_4_0_0, Version.parseLeniently("LUCENE_40"));
|
||||||
assertEquals(Version.LUCENE_CURRENT, Version.parseLeniently("LUCENE_CURRENT"));
|
assertEquals(Version.LUCENE_4_0_0, Version.parseLeniently("LUCENE_4_0"));
|
||||||
|
assertEquals(Version.LATEST, Version.parseLeniently("LATEST"));
|
||||||
|
assertEquals(Version.LATEST, Version.parseLeniently("LUCENE_CURRENT"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParseLenientlyExceptions() {
|
||||||
|
try {
|
||||||
|
Version.parseLeniently("LUCENE");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParse() {
|
||||||
|
assertEquals(Version.LUCENE_5_0_0, Version.parse("5.0.0"));
|
||||||
|
assertEquals(Version.LUCENE_4_1_0, Version.parse("4.1"));
|
||||||
|
assertEquals(Version.LUCENE_4_1_0, Version.parseLeniently("4.1.0"));
|
||||||
|
assertEquals(Version.LUCENE_4_0_0_ALPHA, Version.parseLeniently("4.0.0.1"));
|
||||||
|
assertEquals(Version.LUCENE_4_0_0_BETA, Version.parseLeniently("4.0.0.2"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testForwardsCompatibility() {
|
||||||
|
assertTrue(Version.parse("4.7.10").onOrAfter(Version.LUCENE_4_7_2));
|
||||||
|
assertTrue(Version.parse("4.20.0").onOrAfter(Version.LUCENE_4_8_1));
|
||||||
|
assertTrue(Version.parse("5.10.20").onOrAfter(Version.LUCENE_5_0_0));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testParseExceptions() {
|
||||||
|
try {
|
||||||
|
Version.parse("1.0");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("LUCENE_4_0_0");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.256");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.-1");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.1.256");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.1.-1");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.1.1.3");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.1.1.-1");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.1.1.1");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.1.1.2");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("4.0.0.0");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Version.parse("6.0.0");
|
||||||
|
fail();
|
||||||
|
} catch (IllegalArgumentException iae) {
|
||||||
|
// pass
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeprecations() throws Exception {
|
public void testDeprecations() throws Exception {
|
||||||
Version values[] = Version.values();
|
|
||||||
// all but the latest version should be deprecated
|
// all but the latest version should be deprecated
|
||||||
for (int i = 0; i < values.length; i++) {
|
for (Field field : Version.class.getDeclaredFields()) {
|
||||||
if (i + 1 == values.length) {
|
if (Modifier.isStatic(field.getModifiers()) && field.getType() == Version.class) {
|
||||||
assertSame("Last constant must be LUCENE_CURRENT", Version.LUCENE_CURRENT, values[i]);
|
Version v = (Version)field.get(Version.class);
|
||||||
}
|
final boolean dep = field.isAnnotationPresent(Deprecated.class);
|
||||||
final boolean dep = Version.class.getField(values[i].name()).isAnnotationPresent(Deprecated.class);
|
if (v.equals(Version.LATEST) && field.getName().equals("LUCENE_CURRENT") == false) {
|
||||||
if (i + 2 != values.length) {
|
assertFalse(field.getName() + " should not be deprecated", dep);
|
||||||
assertTrue(values[i].name() + " should be deprecated", dep);
|
} else {
|
||||||
} else {
|
assertTrue(field.getName() + " should be deprecated", dep);
|
||||||
assertFalse(values[i].name() + " should not be deprecated", dep);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAgainstMainVersionConstant() {
|
public void testLatestVersionCommonBuild() {
|
||||||
final Version values[] = Version.values();
|
// common-build.xml sets 'tests.LUCENE_VERSION', if not, we skip this test!
|
||||||
assertTrue(values.length >= 2);
|
String commonBuildVersion = System.getProperty("tests.LUCENE_VERSION");
|
||||||
final String mainVersionWithoutAlphaBeta = Constants.mainVersionWithoutAlphaBeta();
|
assumeTrue("Null 'tests.LUCENE_VERSION' test property. You should run the tests with the official Lucene build file",
|
||||||
final Version mainVersionParsed = Version.parseLeniently(mainVersionWithoutAlphaBeta);
|
commonBuildVersion != null);
|
||||||
assertSame("Constant one before last must be the same as the parsed LUCENE_MAIN_VERSION (without alpha/beta) constant: " +
|
assertEquals("Version.LATEST does not match the one given in common-build.xml",
|
||||||
mainVersionWithoutAlphaBeta,
|
Version.LATEST.toString(), commonBuildVersion);
|
||||||
mainVersionParsed, values[values.length - 2]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
package org.apache.lucene.util;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.util.Comparator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests for StringHelper.getVersionComparator
|
|
||||||
*/
|
|
||||||
public class TestVersionComparator extends LuceneTestCase {
|
|
||||||
public void testVersions() {
|
|
||||||
Comparator<String> comp = StringHelper.getVersionComparator();
|
|
||||||
assertTrue(comp.compare("1", "2") < 0);
|
|
||||||
assertTrue(comp.compare("1", "1") == 0);
|
|
||||||
assertTrue(comp.compare("2", "1") > 0);
|
|
||||||
|
|
||||||
assertTrue(comp.compare("1.1", "1") > 0);
|
|
||||||
assertTrue(comp.compare("1", "1.1") < 0);
|
|
||||||
assertTrue(comp.compare("1.1", "1.1") == 0);
|
|
||||||
|
|
||||||
assertTrue(comp.compare("1.0", "1") == 0);
|
|
||||||
assertTrue(comp.compare("1", "1.0") == 0);
|
|
||||||
assertTrue(comp.compare("1.0.1", "1.0") > 0);
|
|
||||||
assertTrue(comp.compare("1.0", "1.0.1") < 0);
|
|
||||||
|
|
||||||
assertTrue(comp.compare("1.02.003", "1.2.3.0") == 0);
|
|
||||||
assertTrue(comp.compare("1.2.3.0", "1.02.003") == 0);
|
|
||||||
|
|
||||||
assertTrue(comp.compare("1.10", "1.9") > 0);
|
|
||||||
assertTrue(comp.compare("1.9", "1.10") < 0);
|
|
||||||
|
|
||||||
assertTrue(comp.compare("0", "1.0") < 0);
|
|
||||||
assertTrue(comp.compare("00", "1.0") < 0);
|
|
||||||
assertTrue(comp.compare("-1.0", "1.0") < 0);
|
|
||||||
assertTrue(comp.compare("3.0", Integer.toString(Integer.MIN_VALUE)) > 0);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,6 +28,6 @@ public interface FacetExamples {
|
||||||
|
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
/** The Lucene {@link Version} used by the example code. */
|
/** The Lucene {@link Version} used by the example code. */
|
||||||
public static final Version EXAMPLES_VER = Version.LUCENE_5_0;
|
public static final Version EXAMPLES_VER = Version.LUCENE_5_0_0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,13 +41,13 @@ public class FieldTermStack {
|
||||||
LinkedList<TermInfo> termList = new LinkedList<>();
|
LinkedList<TermInfo> termList = new LinkedList<>();
|
||||||
|
|
||||||
//public static void main( String[] args ) throws Exception {
|
//public static void main( String[] args ) throws Exception {
|
||||||
// Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
// Analyzer analyzer = new WhitespaceAnalyzer(Version.LATEST);
|
||||||
// QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "f", analyzer );
|
// QueryParser parser = new QueryParser(Version.LATEST, "f", analyzer );
|
||||||
// Query query = parser.parse( "a x:b" );
|
// Query query = parser.parse( "a x:b" );
|
||||||
// FieldQuery fieldQuery = new FieldQuery( query, true, false );
|
// FieldQuery fieldQuery = new FieldQuery( query, true, false );
|
||||||
|
|
||||||
// Directory dir = new RAMDirectory();
|
// Directory dir = new RAMDirectory();
|
||||||
// IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_CURRENT, analyzer));
|
// IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(Version.LATEST, analyzer));
|
||||||
// Document doc = new Document();
|
// Document doc = new Document();
|
||||||
// FieldType ft = new FieldType(TextField.TYPE_STORED);
|
// FieldType ft = new FieldType(TextField.TYPE_STORED);
|
||||||
// ft.setStoreTermVectors(true);
|
// ft.setStoreTermVectors(true);
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class MultiPassIndexSplitter {
|
||||||
} else {
|
} else {
|
||||||
input = new MultiReader(indexes.toArray(new IndexReader[indexes.size()]));
|
input = new MultiReader(indexes.toArray(new IndexReader[indexes.size()]));
|
||||||
}
|
}
|
||||||
splitter.split(Version.LUCENE_CURRENT, input, dirs, seq);
|
splitter.split(Version.LATEST, input, dirs, seq);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -260,7 +260,7 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable {
|
||||||
if (fieldName.equals("textgrams") && minPrefixChars > 0) {
|
if (fieldName.equals("textgrams") && minPrefixChars > 0) {
|
||||||
// TODO: should use an EdgeNGramTokenFilterFactory here
|
// TODO: should use an EdgeNGramTokenFilterFactory here
|
||||||
TokenFilter filter;
|
TokenFilter filter;
|
||||||
if (matchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
if (matchVersion.onOrAfter(Version.LUCENE_4_4_0)) {
|
||||||
filter = new EdgeNGramTokenFilter(components.getTokenStream(), 1, minPrefixChars);
|
filter = new EdgeNGramTokenFilter(components.getTokenStream(), 1, minPrefixChars);
|
||||||
} else {
|
} else {
|
||||||
filter = new Lucene43EdgeNGramTokenFilter(components.getTokenStream(), 1, minPrefixChars);
|
filter = new Lucene43EdgeNGramTokenFilter(components.getTokenStream(), 1, minPrefixChars);
|
||||||
|
|
|
@ -53,13 +53,13 @@ import org.apache.lucene.store.FlushInfo;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
import org.apache.lucene.util.BytesRef;
|
import org.apache.lucene.util.BytesRef;
|
||||||
import org.apache.lucene.util.Constants;
|
|
||||||
import org.apache.lucene.util.FixedBitSet;
|
import org.apache.lucene.util.FixedBitSet;
|
||||||
import org.apache.lucene.util.IOUtils;
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.LineFileDocs;
|
import org.apache.lucene.util.LineFileDocs;
|
||||||
import org.apache.lucene.util.RamUsageTester;
|
import org.apache.lucene.util.RamUsageTester;
|
||||||
import org.apache.lucene.util.TestUtil;
|
import org.apache.lucene.util.TestUtil;
|
||||||
import org.apache.lucene.util.UnicodeUtil;
|
import org.apache.lucene.util.UnicodeUtil;
|
||||||
|
import org.apache.lucene.util.Version;
|
||||||
import org.apache.lucene.util.automaton.Automaton;
|
import org.apache.lucene.util.automaton.Automaton;
|
||||||
import org.apache.lucene.util.automaton.AutomatonTestUtil.RandomAcceptedStrings;
|
import org.apache.lucene.util.automaton.AutomatonTestUtil.RandomAcceptedStrings;
|
||||||
import org.apache.lucene.util.automaton.AutomatonTestUtil;
|
import org.apache.lucene.util.automaton.AutomatonTestUtil;
|
||||||
|
@ -675,7 +675,7 @@ public abstract class BasePostingsFormatTestCase extends BaseIndexFileFormatTest
|
||||||
// randomly index at lower IndexOption
|
// randomly index at lower IndexOption
|
||||||
private FieldsProducer buildIndex(Directory dir, IndexOptions maxAllowed, boolean allowPayloads, boolean alwaysTestMax) throws IOException {
|
private FieldsProducer buildIndex(Directory dir, IndexOptions maxAllowed, boolean allowPayloads, boolean alwaysTestMax) throws IOException {
|
||||||
Codec codec = getCodec();
|
Codec codec = getCodec();
|
||||||
SegmentInfo segmentInfo = new SegmentInfo(dir, Constants.LUCENE_MAIN_VERSION, "_0", maxDoc, false, codec, null);
|
SegmentInfo segmentInfo = new SegmentInfo(dir, Version.LATEST, "_0", maxDoc, false, codec, null);
|
||||||
|
|
||||||
int maxIndexOption = Arrays.asList(IndexOptions.values()).indexOf(maxAllowed);
|
int maxIndexOption = Arrays.asList(IndexOptions.values()).indexOf(maxAllowed);
|
||||||
if (VERBOSE) {
|
if (VERBOSE) {
|
||||||
|
|
|
@ -373,7 +373,7 @@ public abstract class LuceneTestCase extends Assert {
|
||||||
* Use this constant when creating Analyzers and any other version-dependent stuff.
|
* Use this constant when creating Analyzers and any other version-dependent stuff.
|
||||||
* <p><b>NOTE:</b> Change this when development starts for new Lucene version:
|
* <p><b>NOTE:</b> Change this when development starts for new Lucene version:
|
||||||
*/
|
*/
|
||||||
public static final Version TEST_VERSION_CURRENT = Version.LUCENE_5_0;
|
public static final Version TEST_VERSION_CURRENT = Version.LUCENE_5_0_0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if and only if tests are run in verbose mode. If this flag is false
|
* True if and only if tests are run in verbose mode. If this flag is false
|
||||||
|
|
|
@ -200,7 +200,7 @@
|
||||||
<attribute name="excludes" default="**/pom.xml,**/*.iml"/>
|
<attribute name="excludes" default="**/pom.xml,**/*.iml"/>
|
||||||
<attribute name="metainf.source.dir" default="${common-solr.dir}"/>
|
<attribute name="metainf.source.dir" default="${common-solr.dir}"/>
|
||||||
<attribute name="implementation.title" default="org.apache.solr"/>
|
<attribute name="implementation.title" default="org.apache.solr"/>
|
||||||
<attribute name="spec.version" default="${spec.version}"/>
|
<attribute name="spec.version" default="${version}"/>
|
||||||
<attribute name="manifest.file" default="${manifest.file}"/>
|
<attribute name="manifest.file" default="${manifest.file}"/>
|
||||||
<element name="solr-jarify-filesets" optional="true"/>
|
<element name="solr-jarify-filesets" optional="true"/>
|
||||||
<element name="solr-jarify-additional-manifest-attributes" optional="true"/>
|
<element name="solr-jarify-additional-manifest-attributes" optional="true"/>
|
||||||
|
|
|
@ -187,7 +187,7 @@ public class ICUCollationField extends FieldType {
|
||||||
rbc.setVariableTop(variableTop);
|
rbc.setVariableTop(variableTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
analyzer = new ICUCollationKeyAnalyzer(Version.LUCENE_CURRENT, collator);
|
analyzer = new ICUCollationKeyAnalyzer(Version.LATEST, collator);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -443,14 +443,12 @@ public class Config {
|
||||||
version = Version.parseLeniently(matchVersion);
|
version = Version.parseLeniently(matchVersion);
|
||||||
} catch (IllegalArgumentException iae) {
|
} catch (IllegalArgumentException iae) {
|
||||||
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
|
||||||
"Invalid luceneMatchVersion '" + matchVersion +
|
"Invalid luceneMatchVersion. Should be of the form 'V.V.V' (e.g. 4.8.0)", iae);
|
||||||
"', valid values are: " + Arrays.toString(Version.values()) +
|
|
||||||
" or a string in format 'V.V'", iae);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (version == Version.LUCENE_CURRENT && !versionWarningAlreadyLogged.getAndSet(true)) {
|
if (version == Version.LATEST && !versionWarningAlreadyLogged.getAndSet(true)) {
|
||||||
log.warn(
|
log.warn(
|
||||||
"You should not use LUCENE_CURRENT as luceneMatchVersion property: "+
|
"You should not use LATEST as luceneMatchVersion property: "+
|
||||||
"if you use this setting, and then Solr upgrades to a newer release of Lucene, "+
|
"if you use this setting, and then Solr upgrades to a newer release of Lucene, "+
|
||||||
"sizable changes may happen. If precise back compatibility is important "+
|
"sizable changes may happen. If precise back compatibility is important "+
|
||||||
"then you should instead explicitly specify an actual Lucene version."
|
"then you should instead explicitly specify an actual Lucene version."
|
||||||
|
|
|
@ -163,19 +163,19 @@ public class SolrConfig extends Config {
|
||||||
luceneMatchVersion = getLuceneVersion("luceneMatchVersion");
|
luceneMatchVersion = getLuceneVersion("luceneMatchVersion");
|
||||||
String indexConfigPrefix;
|
String indexConfigPrefix;
|
||||||
|
|
||||||
// Old indexDefaults and mainIndex sections are deprecated and fails fast for luceneMatchVersion=>LUCENE_4_0.
|
// Old indexDefaults and mainIndex sections are deprecated and fails fast for luceneMatchVersion=>LUCENE_4_0_0.
|
||||||
// For older solrconfig.xml's we allow the old sections, but never mixed with the new <indexConfig>
|
// For older solrconfig.xml's we allow the old sections, but never mixed with the new <indexConfig>
|
||||||
boolean hasDeprecatedIndexConfig = (getNode("indexDefaults", false) != null) || (getNode("mainIndex", false) != null);
|
boolean hasDeprecatedIndexConfig = (getNode("indexDefaults", false) != null) || (getNode("mainIndex", false) != null);
|
||||||
boolean hasNewIndexConfig = getNode("indexConfig", false) != null;
|
boolean hasNewIndexConfig = getNode("indexConfig", false) != null;
|
||||||
if(hasDeprecatedIndexConfig){
|
if(hasDeprecatedIndexConfig){
|
||||||
if(luceneMatchVersion.onOrAfter(Version.LUCENE_4_0)) {
|
if(luceneMatchVersion.onOrAfter(Version.LUCENE_4_0_0)) {
|
||||||
throw new SolrException(ErrorCode.FORBIDDEN, "<indexDefaults> and <mainIndex> configuration sections are discontinued. Use <indexConfig> instead.");
|
throw new SolrException(ErrorCode.FORBIDDEN, "<indexDefaults> and <mainIndex> configuration sections are discontinued. Use <indexConfig> instead.");
|
||||||
} else {
|
} else {
|
||||||
// Still allow the old sections for older LuceneMatchVersion's
|
// Still allow the old sections for older LuceneMatchVersion's
|
||||||
if(hasNewIndexConfig) {
|
if(hasNewIndexConfig) {
|
||||||
throw new SolrException(ErrorCode.FORBIDDEN, "Cannot specify both <indexDefaults>, <mainIndex> and <indexConfig> at the same time. Please use <indexConfig> only.");
|
throw new SolrException(ErrorCode.FORBIDDEN, "Cannot specify both <indexDefaults>, <mainIndex> and <indexConfig> at the same time. Please use <indexConfig> only.");
|
||||||
}
|
}
|
||||||
log.warn("<indexDefaults> and <mainIndex> configuration sections are deprecated and will fail for luceneMatchVersion=LUCENE_4_0 and later. Please use <indexConfig> instead.");
|
log.warn("<indexDefaults> and <mainIndex> configuration sections are deprecated and will fail for luceneMatchVersion=LUCENE_4_0_0 and later. Please use <indexConfig> instead.");
|
||||||
defaultIndexConfig = new SolrIndexConfig(this, "indexDefaults", null);
|
defaultIndexConfig = new SolrIndexConfig(this, "indexDefaults", null);
|
||||||
mainIndexConfig = new SolrIndexConfig(this, "mainIndex", defaultIndexConfig);
|
mainIndexConfig = new SolrIndexConfig(this, "mainIndex", defaultIndexConfig);
|
||||||
indexConfigPrefix = "mainIndex";
|
indexConfigPrefix = "mainIndex";
|
||||||
|
|
|
@ -35,7 +35,6 @@ import javax.xml.xpath.XPathConstants;
|
||||||
import javax.xml.xpath.XPathExpressionException;
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
import javax.xml.xpath.XPathFactory;
|
import javax.xml.xpath.XPathFactory;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.lang.reflect.Constructor;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -399,7 +398,7 @@ public final class FieldTypePluginLoader
|
||||||
Version version = (configuredVersion != null) ?
|
Version version = (configuredVersion != null) ?
|
||||||
Config.parseLuceneVersionString(configuredVersion) : schema.getDefaultLuceneMatchVersion();
|
Config.parseLuceneVersionString(configuredVersion) : schema.getDefaultLuceneMatchVersion();
|
||||||
|
|
||||||
if (!version.onOrAfter(Version.LUCENE_4_0)) {
|
if (!version.onOrAfter(Version.LUCENE_4_0_0)) {
|
||||||
log.warn(pluginClassName + " is using deprecated " + version +
|
log.warn(pluginClassName + " is using deprecated " + version +
|
||||||
" emulation. You should at some point declare and reindex to at least 4.0, because " +
|
" emulation. You should at some point declare and reindex to at least 4.0, because " +
|
||||||
"3.x emulation is deprecated and will be removed in 5.0");
|
"3.x emulation is deprecated and will be removed in 5.0");
|
||||||
|
|
|
@ -500,7 +500,7 @@ public class IndexSchema {
|
||||||
similarityFactory = new DefaultSimilarityFactory();
|
similarityFactory = new DefaultSimilarityFactory();
|
||||||
final NamedList similarityParams = new NamedList();
|
final NamedList similarityParams = new NamedList();
|
||||||
Version luceneVersion = getDefaultLuceneMatchVersion();
|
Version luceneVersion = getDefaultLuceneMatchVersion();
|
||||||
if (!luceneVersion.onOrAfter(Version.LUCENE_4_7)) {
|
if (!luceneVersion.onOrAfter(Version.LUCENE_4_7_0)) {
|
||||||
similarityParams.add(DefaultSimilarityFactory.DISCOUNT_OVERLAPS, false);
|
similarityParams.add(DefaultSimilarityFactory.DISCOUNT_OVERLAPS, false);
|
||||||
}
|
}
|
||||||
similarityFactory.init(SolrParams.toSolrParams(similarityParams));
|
similarityFactory.init(SolrParams.toSolrParams(similarityParams));
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TestLuceneMatchVersion extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
// this must match the solrconfig.xml version for this test
|
// this must match the solrconfig.xml version for this test
|
||||||
public static final Version DEFAULT_VERSION =
|
public static final Version DEFAULT_VERSION =
|
||||||
Config.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion", "LUCENE_CURRENT"));
|
Config.parseLuceneVersionString(System.getProperty("tests.luceneMatchVersion", "LATEST"));
|
||||||
|
|
||||||
public void testStandardTokenizerVersions() throws Exception {
|
public void testStandardTokenizerVersions() throws Exception {
|
||||||
assertEquals(DEFAULT_VERSION, solrConfig.luceneMatchVersion);
|
assertEquals(DEFAULT_VERSION, solrConfig.luceneMatchVersion);
|
||||||
|
@ -51,18 +51,17 @@ public class TestLuceneMatchVersion extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
type = schema.getFieldType("text40");
|
type = schema.getFieldType("text40");
|
||||||
ana = (TokenizerChain) type.getIndexAnalyzer();
|
ana = (TokenizerChain) type.getIndexAnalyzer();
|
||||||
assertEquals(Version.LUCENE_4_0, (ana.getTokenizerFactory()).getLuceneMatchVersion());
|
assertEquals(Version.LUCENE_4_0_0, (ana.getTokenizerFactory()).getLuceneMatchVersion());
|
||||||
assertEquals(Version.LUCENE_5_0, (ana.getTokenFilterFactories()[2]).getLuceneMatchVersion());
|
assertEquals(Version.LUCENE_5_0_0, (ana.getTokenFilterFactories()[2]).getLuceneMatchVersion());
|
||||||
|
|
||||||
type = schema.getFieldType("textTurkishAnalyzerDefault");
|
type = schema.getFieldType("textTurkishAnalyzerDefault");
|
||||||
Analyzer ana1 = type.getIndexAnalyzer();
|
Analyzer ana1 = type.getIndexAnalyzer();
|
||||||
assertTrue(ana1 instanceof TurkishAnalyzer);
|
assertTrue(ana1 instanceof TurkishAnalyzer);
|
||||||
System.out.println("DEFAULT_VERSION = " + ana1.getVersion().name());
|
|
||||||
assertEquals(DEFAULT_VERSION, ana1.getVersion());
|
assertEquals(DEFAULT_VERSION, ana1.getVersion());
|
||||||
|
|
||||||
type = schema.getFieldType("textTurkishAnalyzer40");
|
type = schema.getFieldType("textTurkishAnalyzer40");
|
||||||
ana1 = type.getIndexAnalyzer();
|
ana1 = type.getIndexAnalyzer();
|
||||||
assertTrue(ana1 instanceof TurkishAnalyzer);
|
assertTrue(ana1 instanceof TurkishAnalyzer);
|
||||||
assertEquals(Version.LUCENE_4_0, ana1.getVersion());
|
assertEquals(Version.LUCENE_4_0_0, ana1.getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,13 +45,13 @@ public class TestSerializedLuceneMatchVersion extends RestTestBase {
|
||||||
"count(/response/lst[@name='fieldType']) = 1",
|
"count(/response/lst[@name='fieldType']) = 1",
|
||||||
|
|
||||||
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockCharFilterFactory']]"
|
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockCharFilterFactory']]"
|
||||||
+" [str[@name='luceneMatchVersion'][.='LUCENE_4_0']]",
|
+" [str[@name='luceneMatchVersion'][.='4.0.0']]",
|
||||||
|
|
||||||
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenizerFactory']]"
|
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenizerFactory']]"
|
||||||
+" [str[@name='luceneMatchVersion'][.='LUCENE_4_0']]",
|
+" [str[@name='luceneMatchVersion'][.='4.0.0']]",
|
||||||
|
|
||||||
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenFilterFactory']]"
|
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenFilterFactory']]"
|
||||||
+" [str[@name='luceneMatchVersion'][.='LUCENE_4_0']]");
|
+" [str[@name='luceneMatchVersion'][.='4.0.0']]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.solr.search.similarities;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
import org.apache.lucene.search.similarities.DefaultSimilarity;
|
||||||
import org.apache.lucene.search.similarities.Similarity;
|
|
||||||
import org.apache.lucene.util.Version;
|
import org.apache.lucene.util.Version;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
|
|
||||||
|
@ -36,21 +35,21 @@ public class TestNonDefinedSimilarityFactory extends BaseSimilarityTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCurrent() throws Exception {
|
public void testCurrent() throws Exception {
|
||||||
// no sys prop set, rely on LUCENE_CURRENT
|
// no sys prop set, rely on LATEST
|
||||||
initCore("solrconfig-basic.xml","schema-tiny.xml");
|
initCore("solrconfig-basic.xml","schema-tiny.xml");
|
||||||
DefaultSimilarity sim = getSimilarity("text", DefaultSimilarity.class);
|
DefaultSimilarity sim = getSimilarity("text", DefaultSimilarity.class);
|
||||||
assertEquals(true, sim.getDiscountOverlaps());
|
assertEquals(true, sim.getDiscountOverlaps());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test47() throws Exception {
|
public void test47() throws Exception {
|
||||||
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_4_7.toString());
|
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_4_7_0.toString());
|
||||||
initCore("solrconfig-basic.xml","schema-tiny.xml");
|
initCore("solrconfig-basic.xml","schema-tiny.xml");
|
||||||
DefaultSimilarity sim = getSimilarity("text", DefaultSimilarity.class);
|
DefaultSimilarity sim = getSimilarity("text", DefaultSimilarity.class);
|
||||||
assertEquals(true, sim.getDiscountOverlaps());
|
assertEquals(true, sim.getDiscountOverlaps());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test46() throws Exception {
|
public void test46() throws Exception {
|
||||||
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_4_6.toString());
|
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_4_6_0.toString());
|
||||||
initCore("solrconfig-basic.xml","schema-tiny.xml");
|
initCore("solrconfig-basic.xml","schema-tiny.xml");
|
||||||
DefaultSimilarity sim = getSimilarity("text", DefaultSimilarity.class);
|
DefaultSimilarity sim = getSimilarity("text", DefaultSimilarity.class);
|
||||||
assertEquals(false, sim.getDiscountOverlaps());
|
assertEquals(false, sim.getDiscountOverlaps());
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
It is *not* a good example to work from.
|
It is *not* a good example to work from.
|
||||||
-->
|
-->
|
||||||
<config>
|
<config>
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
<!-- The DirectoryFactory to use for indexes.
|
<!-- The DirectoryFactory to use for indexes.
|
||||||
solr.StandardDirectoryFactory, the default, is filesystem based.
|
solr.StandardDirectoryFactory, the default, is filesystem based.
|
||||||
solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
|
solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
It is *not* a good example to work from.
|
It is *not* a good example to work from.
|
||||||
-->
|
-->
|
||||||
<config>
|
<config>
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
<!-- The DirectoryFactory to use for indexes.
|
<!-- The DirectoryFactory to use for indexes.
|
||||||
solr.StandardDirectoryFactory, the default, is filesystem based.
|
solr.StandardDirectoryFactory, the default, is filesystem based.
|
||||||
solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
|
solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
that you fully re-index after changing this setting as it can
|
that you fully re-index after changing this setting as it can
|
||||||
affect both how text is indexed and queried.
|
affect both how text is indexed and queried.
|
||||||
-->
|
-->
|
||||||
<luceneMatchVersion>5.0</luceneMatchVersion>
|
<luceneMatchVersion>5.0.0</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
<!-- <lib/> directives can be used to instruct Solr to load any Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
Loading…
Reference in New Issue