mirror of https://github.com/apache/lucene.git
Merged revision(s) 1591333 from lucene/dev/branches/branch_4x:
LUCENE-5632: Transition Version constants from LUCENE_MN to LUCENE_M_N git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1591365 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
13767516ca
commit
bc0d7bbb25
|
@ -107,6 +107,13 @@ API Changes
|
||||||
longer receives the number of fields that will be added (Robert
|
longer receives the number of fields that will be added (Robert
|
||||||
Muir, Mike McCandless)
|
Muir, Mike McCandless)
|
||||||
|
|
||||||
|
* LUCENE-5632: In preparation for coming Lucene versions, the Version
|
||||||
|
enum constants were renamed to make them better readable. The constant
|
||||||
|
for Lucene 4.9 is now "LUCENE_4_9". Version.parseLeniently() is still
|
||||||
|
able to parse the old strings ("LUCENE_49"). The old identifiers got
|
||||||
|
deprecated and will be removed in Lucene 5.0. (Uwe Schindler,
|
||||||
|
Robert Muir)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
|
|
||||||
* LUCENE-5603: hunspell stemmer more efficiently strips prefixes
|
* LUCENE-5603: hunspell stemmer more efficiently strips prefixes
|
||||||
|
|
|
@ -157,7 +157,7 @@ public abstract class CompoundWordTokenFilterBase extends TokenFilter {
|
||||||
int startOff = CompoundWordTokenFilterBase.this.offsetAtt.startOffset();
|
int startOff = CompoundWordTokenFilterBase.this.offsetAtt.startOffset();
|
||||||
int endOff = CompoundWordTokenFilterBase.this.offsetAtt.endOffset();
|
int endOff = CompoundWordTokenFilterBase.this.offsetAtt.endOffset();
|
||||||
|
|
||||||
if (matchVersion.onOrAfter(Version.LUCENE_44) ||
|
if (matchVersion.onOrAfter(Version.LUCENE_4_4) ||
|
||||||
endOff - startOff != CompoundWordTokenFilterBase.this.termAtt.length()) {
|
endOff - startOff != CompoundWordTokenFilterBase.this.termAtt.length()) {
|
||||||
// if length by start + end offsets doesn't match the term text then assume
|
// if length by start + end offsets doesn't match the term text then assume
|
||||||
// this is a synonym and don't adjust the offsets.
|
// this is a synonym and don't adjust the offsets.
|
||||||
|
|
|
@ -208,7 +208,7 @@ public final class WordDelimiterFilter extends TokenFilter {
|
||||||
*/
|
*/
|
||||||
public WordDelimiterFilter(Version matchVersion, TokenStream in, byte[] charTypeTable, int configurationFlags, CharArraySet protWords) {
|
public WordDelimiterFilter(Version matchVersion, TokenStream in, byte[] charTypeTable, int configurationFlags, CharArraySet protWords) {
|
||||||
super(in);
|
super(in);
|
||||||
if (!matchVersion.onOrAfter(Version.LUCENE_48)) {
|
if (!matchVersion.onOrAfter(Version.LUCENE_4_8)) {
|
||||||
throw new IllegalArgumentException("This class only works with Lucene 4.8+. To emulate the old (broken) behavior of WordDelimiterFilter, use Lucene47WordDelimiterFilter");
|
throw new IllegalArgumentException("This class only works with Lucene 4.8+. To emulate the old (broken) behavior of WordDelimiterFilter, use Lucene47WordDelimiterFilter");
|
||||||
}
|
}
|
||||||
this.flags = configurationFlags;
|
this.flags = configurationFlags;
|
||||||
|
|
|
@ -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_48)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_8)) {
|
||||||
return new WordDelimiterFilter(luceneMatchVersion, input, typeTable == null ? WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE : typeTable,
|
return new WordDelimiterFilter(luceneMatchVersion, input, typeTable == null ? WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE : typeTable,
|
||||||
flags, protectedWords);
|
flags, protectedWords);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -79,7 +79,7 @@ public final class EdgeNGramTokenFilter extends TokenFilter {
|
||||||
throw new IllegalArgumentException("minGram must not be greater than maxGram");
|
throw new IllegalArgumentException("minGram must not be greater than maxGram");
|
||||||
}
|
}
|
||||||
|
|
||||||
this.charUtils = version.onOrAfter(Version.LUCENE_44)
|
this.charUtils = version.onOrAfter(Version.LUCENE_4_4)
|
||||||
? CharacterUtils.getInstance(version)
|
? CharacterUtils.getInstance(version)
|
||||||
: CharacterUtils.getJava4Instance();
|
: CharacterUtils.getJava4Instance();
|
||||||
this.minGram = minGram;
|
this.minGram = minGram;
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.apache.lucene.util.Version;
|
||||||
* increasing length (meaning that "abc" will give "a", "ab", "abc", "b", "bc",
|
* increasing length (meaning that "abc" will give "a", "ab", "abc", "b", "bc",
|
||||||
* "c").</li></ul>
|
* "c").</li></ul>
|
||||||
* <p>You can make this filter use the old behavior by providing a version <
|
* <p>You can make this filter use the old behavior by providing a version <
|
||||||
* {@link Version#LUCENE_44} in the constructor but this is not recommended as
|
* {@link Version#LUCENE_4_4} in the constructor but this is not recommended as
|
||||||
* it will lead to broken {@link TokenStream}s that will cause highlighting
|
* it will lead to broken {@link TokenStream}s that will cause highlighting
|
||||||
* bugs.
|
* bugs.
|
||||||
* <p>If you were using this {@link TokenFilter} to perform partial highlighting,
|
* <p>If you were using this {@link TokenFilter} to perform partial highlighting,
|
||||||
|
@ -83,7 +83,7 @@ public final class NGramTokenFilter extends TokenFilter {
|
||||||
public NGramTokenFilter(Version version, TokenStream input, int minGram, int maxGram) {
|
public NGramTokenFilter(Version version, TokenStream input, int minGram, int maxGram) {
|
||||||
super(new CodepointCountFilter(version, input, minGram, Integer.MAX_VALUE));
|
super(new CodepointCountFilter(version, input, minGram, Integer.MAX_VALUE));
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.charUtils = version.onOrAfter(Version.LUCENE_44)
|
this.charUtils = version.onOrAfter(Version.LUCENE_4_4)
|
||||||
? CharacterUtils.getInstance(version)
|
? CharacterUtils.getInstance(version)
|
||||||
: CharacterUtils.getJava4Instance();
|
: CharacterUtils.getJava4Instance();
|
||||||
if (minGram < 1) {
|
if (minGram < 1) {
|
||||||
|
@ -94,7 +94,7 @@ public final class NGramTokenFilter extends TokenFilter {
|
||||||
}
|
}
|
||||||
this.minGram = minGram;
|
this.minGram = minGram;
|
||||||
this.maxGram = maxGram;
|
this.maxGram = maxGram;
|
||||||
if (version.onOrAfter(Version.LUCENE_44)) {
|
if (version.onOrAfter(Version.LUCENE_4_4)) {
|
||||||
posIncAtt = addAttribute(PositionIncrementAttribute.class);
|
posIncAtt = addAttribute(PositionIncrementAttribute.class);
|
||||||
posLenAtt = addAttribute(PositionLengthAttribute.class);
|
posLenAtt = addAttribute(PositionLengthAttribute.class);
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,7 +149,7 @@ public final class NGramTokenFilter extends TokenFilter {
|
||||||
hasIllegalOffsets = (tokStart + curTermLength) != tokEnd;
|
hasIllegalOffsets = (tokStart + curTermLength) != tokEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (version.onOrAfter(Version.LUCENE_44)) {
|
if (version.onOrAfter(Version.LUCENE_4_4)) {
|
||||||
if (curGramSize > maxGram || (curPos + curGramSize) > curCodePointCount) {
|
if (curGramSize > maxGram || (curPos + curGramSize) > curCodePointCount) {
|
||||||
++curPos;
|
++curPos;
|
||||||
curGramSize = minGram;
|
curGramSize = minGram;
|
||||||
|
|
|
@ -116,10 +116,10 @@ public class NGramTokenizer extends Tokenizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(Version version, int minGram, int maxGram, boolean edgesOnly) {
|
private void init(Version version, int minGram, int maxGram, boolean edgesOnly) {
|
||||||
if (!edgesOnly && !version.onOrAfter(Version.LUCENE_44)) {
|
if (!edgesOnly && !version.onOrAfter(Version.LUCENE_4_4)) {
|
||||||
throw new IllegalArgumentException("This class only works with Lucene 4.4+. To emulate the old (broken) behavior of NGramTokenizer, use Lucene43NGramTokenizer");
|
throw new IllegalArgumentException("This class only works with Lucene 4.4+. To emulate the old (broken) behavior of NGramTokenizer, use Lucene43NGramTokenizer");
|
||||||
}
|
}
|
||||||
charUtils = version.onOrAfter(Version.LUCENE_44)
|
charUtils = version.onOrAfter(Version.LUCENE_4_4)
|
||||||
? CharacterUtils.getInstance(version)
|
? CharacterUtils.getInstance(version)
|
||||||
: CharacterUtils.getJava4Instance();
|
: CharacterUtils.getJava4Instance();
|
||||||
if (minGram < 1) {
|
if (minGram < 1) {
|
||||||
|
|
|
@ -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_44)) {
|
if (luceneMatchVersion.onOrAfter(Version.LUCENE_4_4)) {
|
||||||
return new NGramTokenizer(luceneMatchVersion, factory, minGramSize, maxGramSize);
|
return new NGramTokenizer(luceneMatchVersion, factory, minGramSize, maxGramSize);
|
||||||
} else {
|
} else {
|
||||||
return new Lucene43NGramTokenizer(factory, minGramSize, maxGramSize);
|
return new Lucene43NGramTokenizer(factory, minGramSize, maxGramSize);
|
||||||
|
|
|
@ -102,7 +102,7 @@ public final class ThaiAnalyzer extends StopwordAnalyzerBase {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected TokenStreamComponents createComponents(String fieldName) {
|
protected TokenStreamComponents createComponents(String fieldName) {
|
||||||
if (matchVersion.onOrAfter(Version.LUCENE_48)) {
|
if (matchVersion.onOrAfter(Version.LUCENE_4_8)) {
|
||||||
final Tokenizer source = new ThaiTokenizer();
|
final Tokenizer source = new ThaiTokenizer();
|
||||||
TokenStream result = new LowerCaseFilter(matchVersion, source);
|
TokenStream result = new LowerCaseFilter(matchVersion, source);
|
||||||
result = new StopFilter(matchVersion, result, stopwords);
|
result = new StopFilter(matchVersion, result, stopwords);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public final class TurkishAnalyzer extends StopwordAnalyzerBase {
|
||||||
protected TokenStreamComponents createComponents(String fieldName) {
|
protected TokenStreamComponents createComponents(String fieldName) {
|
||||||
final Tokenizer source = new StandardTokenizer(matchVersion);
|
final Tokenizer source = new StandardTokenizer(matchVersion);
|
||||||
TokenStream result = new StandardFilter(matchVersion, source);
|
TokenStream result = new StandardFilter(matchVersion, source);
|
||||||
if(matchVersion.onOrAfter(Version.LUCENE_48))
|
if(matchVersion.onOrAfter(Version.LUCENE_4_8))
|
||||||
result = new ApostropheFilter(result);
|
result = new ApostropheFilter(result);
|
||||||
result = new TurkishLowerCaseFilter(result);
|
result = new TurkishLowerCaseFilter(result);
|
||||||
result = new StopFilter(matchVersion, result, stopwords);
|
result = new StopFilter(matchVersion, result, stopwords);
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class TestStopFilter extends BaseTokenStreamTestCase {
|
||||||
StringReader reader = new StringReader(sb.toString());
|
StringReader reader = new StringReader(sb.toString());
|
||||||
final MockTokenizer in = new MockTokenizer(MockTokenizer.WHITESPACE, false);
|
final MockTokenizer in = new MockTokenizer(MockTokenizer.WHITESPACE, false);
|
||||||
in.setReader(reader);
|
in.setReader(reader);
|
||||||
StopFilter stpf = new StopFilter(Version.LUCENE_40, in, stopSet);
|
StopFilter stpf = new StopFilter(Version.LUCENE_4_0, in, stopSet);
|
||||||
doTestStopPositons(stpf);
|
doTestStopPositons(stpf);
|
||||||
// with increments, concatenating two stop filters
|
// with increments, concatenating two stop filters
|
||||||
ArrayList<String> a0 = new ArrayList<>();
|
ArrayList<String> a0 = new ArrayList<>();
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class NGramTokenFilterTest extends BaseTokenStreamTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLucene43() throws IOException {
|
public void testLucene43() throws IOException {
|
||||||
NGramTokenFilter filter = new NGramTokenFilter(Version.LUCENE_43, input, 2, 3);
|
NGramTokenFilter filter = new NGramTokenFilter(Version.LUCENE_4_3, input, 2, 3);
|
||||||
assertTokenStreamContents(filter,
|
assertTokenStreamContents(filter,
|
||||||
new String[]{"ab","bc","cd","de","abc","bcd","cde"},
|
new String[]{"ab","bc","cd","de","abc","bcd","cde"},
|
||||||
new int[]{0,1,2,3,0,1,2},
|
new int[]{0,1,2,3,0,1,2},
|
||||||
|
|
|
@ -115,9 +115,9 @@ algorithm.
|
||||||
<h3>Farsi Range Queries</h3>
|
<h3>Farsi Range Queries</h3>
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
Collator collator = Collator.getInstance(new ULocale("ar"));
|
Collator collator = Collator.getInstance(new ULocale("ar"));
|
||||||
ICUCollationKeyAnalyzer analyzer = new ICUCollationKeyAnalyzer(Version.LUCENE_50, collator);
|
ICUCollationKeyAnalyzer analyzer = new ICUCollationKeyAnalyzer(Version.LUCENE_5_0, collator);
|
||||||
RAMDirectory ramDir = new RAMDirectory();
|
RAMDirectory ramDir = new RAMDirectory();
|
||||||
IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(Version.LUCENE_50, analyzer));
|
IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(Version.LUCENE_5_0, analyzer));
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(new Field("content", "\u0633\u0627\u0628",
|
doc.add(new Field("content", "\u0633\u0627\u0628",
|
||||||
Field.Store.YES, Field.Index.ANALYZED));
|
Field.Store.YES, Field.Index.ANALYZED));
|
||||||
|
@ -125,7 +125,7 @@ algorithm.
|
||||||
writer.close();
|
writer.close();
|
||||||
IndexSearcher is = new IndexSearcher(ramDir, true);
|
IndexSearcher is = new IndexSearcher(ramDir, true);
|
||||||
|
|
||||||
QueryParser aqp = new QueryParser(Version.LUCENE_50, "content", analyzer);
|
QueryParser aqp = new QueryParser(Version.LUCENE_5_0, "content", analyzer);
|
||||||
aqp.setAnalyzeRangeTerms(true);
|
aqp.setAnalyzeRangeTerms(true);
|
||||||
|
|
||||||
// Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
|
// Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
|
||||||
|
@ -141,9 +141,9 @@ algorithm.
|
||||||
<h3>Danish Sorting</h3>
|
<h3>Danish Sorting</h3>
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
Analyzer analyzer
|
Analyzer analyzer
|
||||||
= new ICUCollationKeyAnalyzer(Version.LUCENE_50, Collator.getInstance(new ULocale("da", "dk")));
|
= new ICUCollationKeyAnalyzer(Version.LUCENE_5_0, Collator.getInstance(new ULocale("da", "dk")));
|
||||||
RAMDirectory indexStore = new RAMDirectory();
|
RAMDirectory indexStore = new RAMDirectory();
|
||||||
IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig(Version.LUCENE_50, analyzer));
|
IndexWriter writer = new IndexWriter(indexStore, new IndexWriterConfig(Version.LUCENE_5_0, analyzer));
|
||||||
String[] tracer = new String[] { "A", "B", "C", "D", "E" };
|
String[] tracer = new String[] { "A", "B", "C", "D", "E" };
|
||||||
String[] data = new String[] { "HAT", "HUT", "H\u00C5T", "H\u00D8T", "HOT" };
|
String[] data = new String[] { "HAT", "HUT", "H\u00C5T", "H\u00D8T", "HOT" };
|
||||||
String[] sortedTracerOrder = new String[] { "A", "E", "B", "D", "C" };
|
String[] sortedTracerOrder = new String[] { "A", "E", "B", "D", "C" };
|
||||||
|
@ -169,15 +169,15 @@ algorithm.
|
||||||
<pre class="prettyprint">
|
<pre class="prettyprint">
|
||||||
Collator collator = Collator.getInstance(new ULocale("tr", "TR"));
|
Collator collator = Collator.getInstance(new ULocale("tr", "TR"));
|
||||||
collator.setStrength(Collator.PRIMARY);
|
collator.setStrength(Collator.PRIMARY);
|
||||||
Analyzer analyzer = new ICUCollationKeyAnalyzer(Version.LUCENE_50, collator);
|
Analyzer analyzer = new ICUCollationKeyAnalyzer(Version.LUCENE_5_0, collator);
|
||||||
RAMDirectory ramDir = new RAMDirectory();
|
RAMDirectory ramDir = new RAMDirectory();
|
||||||
IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(Version.LUCENE_50, analyzer));
|
IndexWriter writer = new IndexWriter(ramDir, new IndexWriterConfig(Version.LUCENE_5_0, analyzer));
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(new Field("contents", "DIGY", Field.Store.NO, Field.Index.ANALYZED));
|
doc.add(new Field("contents", "DIGY", Field.Store.NO, Field.Index.ANALYZED));
|
||||||
writer.addDocument(doc);
|
writer.addDocument(doc);
|
||||||
writer.close();
|
writer.close();
|
||||||
IndexSearcher is = new IndexSearcher(ramDir, true);
|
IndexSearcher is = new IndexSearcher(ramDir, true);
|
||||||
QueryParser parser = new QueryParser(Version.LUCENE_50, "contents", analyzer);
|
QueryParser parser = new QueryParser(Version.LUCENE_5_0, "contents", analyzer);
|
||||||
Query query = parser.parse("d\u0131gy"); // U+0131: dotless i
|
Query query = parser.parse("d\u0131gy"); // U+0131: dotless i
|
||||||
ScoreDoc[] result = is.search(query, null, 1000).scoreDocs;
|
ScoreDoc[] result = is.search(query, null, 1000).scoreDocs;
|
||||||
assertEquals("The index Term should be included.", 1, result.length);
|
assertEquals("The index Term should be included.", 1, result.length);
|
||||||
|
|
|
@ -137,7 +137,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 (matchVersion.onOrAfter(Version.LUCENE_48)) {
|
if (matchVersion.onOrAfter(Version.LUCENE_4_8)) {
|
||||||
tokenizer = new HMMChineseTokenizer();
|
tokenizer = new HMMChineseTokenizer();
|
||||||
result = tokenizer;
|
result = tokenizer;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
# * limitations under the License.
|
# * limitations under the License.
|
||||||
# */
|
# */
|
||||||
|
|
||||||
writer.version=LUCENE_40
|
writer.version=4.0
|
||||||
|
|
||||||
analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
|
analyzer=org.apache.lucene.analysis.standard.StandardAnalyzer
|
||||||
directory=FSDirectory
|
directory=FSDirectory
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
||||||
|
|
||||||
writer.version=LUCENE_40
|
writer.version=4.0
|
||||||
#merge.factor=mrg:10:100:10:100:10:100:10:100
|
#merge.factor=mrg:10:100:10:100:10:100:10:100
|
||||||
#max.buffered=buf:10:10:100:100:10:10:100:100
|
#max.buffered=buf:10:10:100:100:10:10:100:100
|
||||||
ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
||||||
|
|
||||||
writer.version=LUCENE_40
|
writer.version=4.0
|
||||||
#merge.factor=mrg:10:100:10:100:10:100:10:100
|
#merge.factor=mrg:10:100:10:100:10:100:10:100
|
||||||
#max.buffered=buf:10:10:100:100:10:10:100:100
|
#max.buffered=buf:10:10:100:100:10:10:100:100
|
||||||
ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
||||||
|
|
||||||
writer.version=LUCENE_40
|
writer.version=4.0
|
||||||
merge.factor=mrg:10:100:10:100:10:100:10:100
|
merge.factor=mrg:10:100:10:100:10:100:10:100
|
||||||
max.buffered=buf:10:10:100:100:10:10:100:100
|
max.buffered=buf:10:10:100:100:10:10:100:100
|
||||||
#ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
#ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
||||||
|
|
||||||
writer.version=LUCENE_40
|
writer.version=4.0
|
||||||
merge.factor=mrg:10:100:10:100:10:100:10:100
|
merge.factor=mrg:10:100:10:100:10:100:10:100
|
||||||
max.buffered=buf:10:10:100:100:10:10:100:100
|
max.buffered=buf:10:10:100:100:10:10:100:100
|
||||||
#ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
#ram.flush.mb=flush:32:40:48:56:32:40:48:56
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
# -------------------------------------------------------------------------------------
|
# -------------------------------------------------------------------------------------
|
||||||
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
# multi val params are iterated by NewRound's, added to reports, start with column name.
|
||||||
|
|
||||||
writer.version=LUCENE_40
|
writer.version=4.0
|
||||||
merge.factor=mrg:10:100:10:100:10:100:10:100
|
merge.factor=mrg:10:100:10:100:10:100:10:100
|
||||||
max.buffered=buf:10:10:100:100:10:10:100:100
|
max.buffered=buf:10:10:100:100:10:10:100:100
|
||||||
compound=cmpnd:true:true:true:true:false:false:false:false
|
compound=cmpnd:true:true:true:true:false:false:false:false
|
||||||
|
|
|
@ -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_42),
|
* WhitespaceTokenizer(luceneMatchVersion:LUCENE_5_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')
|
||||||
|
|
|
@ -96,8 +96,8 @@ public class CreateIndexTask extends PerfTask {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IndexWriterConfig createWriterConfig(Config config, PerfRunData runData, OpenMode mode, IndexCommit commit) {
|
public static IndexWriterConfig createWriterConfig(Config config, PerfRunData runData, OpenMode mode, IndexCommit commit) {
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
@SuppressWarnings("deprecation")
|
||||||
Version version = Version.valueOf(config.get("writer.version", Version.LUCENE_50.toString()));
|
Version version = Version.parseLeniently(config.get("writer.version", Version.LUCENE_CURRENT.toString()));
|
||||||
IndexWriterConfig iwConf = new IndexWriterConfig(version, runData.getAnalyzer());
|
IndexWriterConfig iwConf = new IndexWriterConfig(version, runData.getAnalyzer());
|
||||||
iwConf.setOpenMode(mode);
|
iwConf.setOpenMode(mode);
|
||||||
IndexDeletionPolicy indexDeletionPolicy = getIndexDeletionPolicy(config);
|
IndexDeletionPolicy indexDeletionPolicy = getIndexDeletionPolicy(config);
|
||||||
|
|
|
@ -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_50.toString());
|
props.setProperty("writer.version", Version.LUCENE_5_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) {
|
||||||
|
|
|
@ -70,9 +70,9 @@ public class DatasetSplitter {
|
||||||
|
|
||||||
// create IWs for train / test / cv IDXs
|
// create IWs for train / test / cv IDXs
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
IndexWriter testWriter = new IndexWriter(testIndex, new IndexWriterConfig(Version.LUCENE_50, analyzer));
|
IndexWriter testWriter = new IndexWriter(testIndex, new IndexWriterConfig(Version.LUCENE_5_0, analyzer));
|
||||||
IndexWriter cvWriter = new IndexWriter(crossValidationIndex, new IndexWriterConfig(Version.LUCENE_50, analyzer));
|
IndexWriter cvWriter = new IndexWriter(crossValidationIndex, new IndexWriterConfig(Version.LUCENE_5_0, analyzer));
|
||||||
IndexWriter trainingWriter = new IndexWriter(trainingIndex, new IndexWriterConfig(Version.LUCENE_50, analyzer));
|
IndexWriter trainingWriter = new IndexWriter(trainingIndex, new IndexWriterConfig(Version.LUCENE_5_0, analyzer));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int size = originalIndex.maxDoc();
|
int size = originalIndex.maxDoc();
|
||||||
|
|
|
@ -908,7 +908,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
* If there are running merges or uncommitted
|
* If there are running merges or uncommitted
|
||||||
* changes:
|
* changes:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li> If config.matchVersion >= LUCENE_50 then the
|
* <li> If config.matchVersion >= LUCENE_5_0 then the
|
||||||
* changes are silently discarded.
|
* changes are silently discarded.
|
||||||
* <li> Otherwise, a RuntimeException is thrown to
|
* <li> Otherwise, a RuntimeException is thrown to
|
||||||
* indicate what was lost, but the IndexWriter is
|
* indicate what was lost, but the IndexWriter is
|
||||||
|
@ -921,7 +921,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
* @throws IOException if there is a low-level IO error
|
* @throws IOException if there is a low-level IO error
|
||||||
* (the IndexWriter will still be closed)
|
* (the IndexWriter will still be closed)
|
||||||
* @throws RuntimeException if config.matchVersion <
|
* @throws RuntimeException if config.matchVersion <
|
||||||
* LUCENE_50 and there were pending changes that were
|
* LUCENE_5_0 and there were pending changes that were
|
||||||
* lost (the IndexWriter will still be closed)
|
* lost (the IndexWriter will still be closed)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -934,7 +934,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit{
|
||||||
boolean lostChanges = false;
|
boolean lostChanges = false;
|
||||||
|
|
||||||
// Only check for lost changes if the version earlier than 5.0:
|
// Only check for lost changes if the version earlier than 5.0:
|
||||||
if (config.getMatchVersion().onOrAfter(Version.LUCENE_50) == false) {
|
if (config.getMatchVersion().onOrAfter(Version.LUCENE_5_0) == false) {
|
||||||
lostChanges = hasUncommittedChanges();
|
lostChanges = hasUncommittedChanges();
|
||||||
if (lostChanges == false) {
|
if (lostChanges == false) {
|
||||||
synchronized(this) {
|
synchronized(this) {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.util.IOUtils;
|
||||||
// - let subclass dictate policy...?
|
// - let subclass dictate policy...?
|
||||||
// - rename to MergeCacheingDir? NRTCachingDir
|
// - rename to MergeCacheingDir? NRTCachingDir
|
||||||
|
|
||||||
|
// :Post-Release-Update-Version.LUCENE_X_Y: (in <pre> block in javadoc below)
|
||||||
/**
|
/**
|
||||||
* Wraps a {@link RAMDirectory}
|
* Wraps a {@link RAMDirectory}
|
||||||
* around any provided delegate directory, to
|
* around any provided delegate directory, to
|
||||||
|
@ -50,7 +51,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_50, analyzer);
|
* IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_5_0, analyzer);
|
||||||
* IndexWriter writer = new IndexWriter(cachedFSDir, conf);
|
* IndexWriter writer = new IndexWriter(cachedFSDir, conf);
|
||||||
* </pre>
|
* </pre>
|
||||||
*
|
*
|
||||||
|
|
|
@ -38,77 +38,77 @@ public enum Version {
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_40,
|
LUCENE_4_0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.1 release.
|
* Match settings and bugs in Lucene's 4.1 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_41,
|
LUCENE_4_1,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.2 release.
|
* Match settings and bugs in Lucene's 4.2 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_42,
|
LUCENE_4_2,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.3 release.
|
* Match settings and bugs in Lucene's 4.3 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_43,
|
LUCENE_4_3,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.4 release.
|
* Match settings and bugs in Lucene's 4.4 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_44,
|
LUCENE_4_4,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.5 release.
|
* Match settings and bugs in Lucene's 4.5 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_45,
|
LUCENE_4_5,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.6 release.
|
* Match settings and bugs in Lucene's 4.6 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_46,
|
LUCENE_4_6,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.7 release.
|
* Match settings and bugs in Lucene's 4.7 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_47,
|
LUCENE_4_7,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.8 release.
|
* Match settings and bugs in Lucene's 4.8 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_48,
|
LUCENE_4_8,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Match settings and bugs in Lucene's 4.9 release.
|
* Match settings and bugs in Lucene's 4.9 release.
|
||||||
* @deprecated (5.0) Use latest
|
* @deprecated (5.0) Use latest
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
LUCENE_49,
|
LUCENE_4_9,
|
||||||
|
|
||||||
/** 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_50,
|
LUCENE_5_0,
|
||||||
|
|
||||||
/* Add new constants for later versions **here** to respect order! */
|
/* Add new constants for later versions **here** to respect order! */
|
||||||
|
|
||||||
|
@ -136,7 +136,10 @@ public enum Version {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Version parseLeniently(String version) {
|
public static Version parseLeniently(String version) {
|
||||||
String parsedMatchVersion = version.toUpperCase(Locale.ROOT);
|
final String parsedMatchVersion = version
|
||||||
return Version.valueOf(parsedMatchVersion.replaceFirst("^(\\d)\\.(\\d)$", "LUCENE_$1$2"));
|
.toUpperCase(Locale.ROOT)
|
||||||
|
.replaceFirst("^(\\d+)\\.(\\d+)$", "LUCENE_$1_$2")
|
||||||
|
.replaceFirst("^LUCENE_(\\d)(\\d)$", "LUCENE_$1_$2");
|
||||||
|
return Version.valueOf(parsedMatchVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2431,7 +2431,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
Directory dir = newDirectory();
|
Directory dir = newDirectory();
|
||||||
// If version is < 50 IW.close should throw an exception
|
// If version is < 50 IW.close should throw an exception
|
||||||
// on uncommitted changes:
|
// on uncommitted changes:
|
||||||
IndexWriterConfig iwc = newIndexWriterConfig(Version.LUCENE_48, new MockAnalyzer(random()));
|
IndexWriterConfig iwc = newIndexWriterConfig(Version.LUCENE_4_8, new MockAnalyzer(random()));
|
||||||
IndexWriter w = new IndexWriter(dir, iwc);
|
IndexWriter w = new IndexWriter(dir, iwc);
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
|
doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
|
||||||
|
@ -2455,7 +2455,7 @@ public class TestIndexWriter extends LuceneTestCase {
|
||||||
|
|
||||||
// If version is < 50 IW.close should throw an exception
|
// If version is < 50 IW.close should throw an exception
|
||||||
// on still-running merges:
|
// on still-running merges:
|
||||||
IndexWriterConfig iwc = newIndexWriterConfig(Version.LUCENE_48, new MockAnalyzer(random()));
|
IndexWriterConfig iwc = newIndexWriterConfig(Version.LUCENE_4_8, new MockAnalyzer(random()));
|
||||||
LogDocMergePolicy mp = new LogDocMergePolicy();
|
LogDocMergePolicy mp = new LogDocMergePolicy();
|
||||||
mp.setMergeFactor(2);
|
mp.setMergeFactor(2);
|
||||||
iwc.setMergePolicy(mp);
|
iwc.setMergePolicy(mp);
|
||||||
|
|
|
@ -475,7 +475,7 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
|
||||||
|
|
||||||
final SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
|
final SnapshotDeletionPolicy sdp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy());
|
||||||
final Directory dir = new NRTCachingDirectory(newFSDirectory(createTempDir("nrt")), 5, 128);
|
final Directory dir = new NRTCachingDirectory(newFSDirectory(createTempDir("nrt")), 5, 128);
|
||||||
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_46,
|
IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_6,
|
||||||
new MockAnalyzer(random()));
|
new MockAnalyzer(random()));
|
||||||
config.setIndexDeletionPolicy(sdp);
|
config.setIndexDeletionPolicy(sdp);
|
||||||
config.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
|
config.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
|
||||||
|
|
|
@ -23,13 +23,14 @@ public class TestVersion extends LuceneTestCase {
|
||||||
for (Version v : Version.values()) {
|
for (Version v : Version.values()) {
|
||||||
assertTrue("LUCENE_CURRENT must be always onOrAfter("+v+")", Version.LUCENE_CURRENT.onOrAfter(v));
|
assertTrue("LUCENE_CURRENT must be always onOrAfter("+v+")", Version.LUCENE_CURRENT.onOrAfter(v));
|
||||||
}
|
}
|
||||||
assertTrue(Version.LUCENE_50.onOrAfter(Version.LUCENE_40));
|
assertTrue(Version.LUCENE_5_0.onOrAfter(Version.LUCENE_4_0));
|
||||||
assertFalse(Version.LUCENE_40.onOrAfter(Version.LUCENE_50));
|
assertFalse(Version.LUCENE_4_0.onOrAfter(Version.LUCENE_5_0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testParseLeniently() {
|
public void testParseLeniently() {
|
||||||
assertEquals(Version.LUCENE_40, Version.parseLeniently("4.0"));
|
assertEquals(Version.LUCENE_4_0, Version.parseLeniently("4.0"));
|
||||||
assertEquals(Version.LUCENE_40, Version.parseLeniently("LUCENE_40"));
|
assertEquals(Version.LUCENE_4_0, Version.parseLeniently("LUCENE_40"));
|
||||||
|
assertEquals(Version.LUCENE_4_0, Version.parseLeniently("LUCENE_4_0"));
|
||||||
assertEquals(Version.LUCENE_CURRENT, Version.parseLeniently("LUCENE_CURRENT"));
|
assertEquals(Version.LUCENE_CURRENT, Version.parseLeniently("LUCENE_CURRENT"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,8 +88,8 @@ public class IndexFiles {
|
||||||
|
|
||||||
Directory dir = FSDirectory.open(new File(indexPath));
|
Directory dir = FSDirectory.open(new File(indexPath));
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_50);
|
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_5_0);
|
||||||
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_50, analyzer);
|
IndexWriterConfig iwc = new IndexWriterConfig(Version.LUCENE_5_0, analyzer);
|
||||||
|
|
||||||
if (create) {
|
if (create) {
|
||||||
// Create a new index in the directory, removing any
|
// Create a new index in the directory, removing any
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class SearchFiles {
|
||||||
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(index)));
|
IndexReader reader = DirectoryReader.open(FSDirectory.open(new File(index)));
|
||||||
IndexSearcher searcher = new IndexSearcher(reader);
|
IndexSearcher searcher = new IndexSearcher(reader);
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_50);
|
Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_5_0);
|
||||||
|
|
||||||
BufferedReader in = null;
|
BufferedReader in = null;
|
||||||
if (queries != null) {
|
if (queries != null) {
|
||||||
|
@ -101,7 +101,7 @@ public class SearchFiles {
|
||||||
in = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
in = new BufferedReader(new InputStreamReader(System.in, StandardCharsets.UTF_8));
|
||||||
}
|
}
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
QueryParser parser = new QueryParser(Version.LUCENE_50, field, analyzer);
|
QueryParser parser = new QueryParser(Version.LUCENE_5_0, field, analyzer);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (queries == null && queryString == null) { // prompt the user
|
if (queries == null && queryString == null) { // prompt the user
|
||||||
System.out.println("Enter query: ");
|
System.out.println("Enter query: ");
|
||||||
|
|
|
@ -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_50;
|
public static final Version EXAMPLES_VER = Version.LUCENE_5_0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ public class DirectoryTaxonomyWriter implements TaxonomyWriter {
|
||||||
// :Post-Release-Update-Version.LUCENE_XY:
|
// :Post-Release-Update-Version.LUCENE_XY:
|
||||||
// Make sure we use a MergePolicy which always merges adjacent segments and thus
|
// Make sure we use a MergePolicy which always merges adjacent segments and thus
|
||||||
// keeps the doc IDs ordered as well (this is crucial for the taxonomy index).
|
// keeps the doc IDs ordered as well (this is crucial for the taxonomy index).
|
||||||
return new IndexWriterConfig(Version.LUCENE_50, null).setOpenMode(openMode).setMergePolicy(
|
return new IndexWriterConfig(Version.LUCENE_5_0, null).setOpenMode(openMode).setMergePolicy(
|
||||||
new LogByteSizeMergePolicy());
|
new LogByteSizeMergePolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class TestMultiAnalyzer extends BaseTokenStreamTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPosIncrementAnalyzer() throws ParseException {
|
public void testPosIncrementAnalyzer() throws ParseException {
|
||||||
QueryParser qp = new QueryParser(Version.LUCENE_40, "", new PosIncrementAnalyzer());
|
QueryParser qp = new QueryParser(Version.LUCENE_4_0, "", new PosIncrementAnalyzer());
|
||||||
assertEquals("quick brown", qp.parse("the quick brown").toString());
|
assertEquals("quick brown", qp.parse("the quick brown").toString());
|
||||||
assertEquals("quick brown fox", qp.parse("the quick brown fox").toString());
|
assertEquals("quick brown fox", qp.parse("the quick brown fox").toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,7 +374,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_50;
|
public static final Version TEST_VERSION_CURRENT = Version.LUCENE_5_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
|
||||||
|
|
|
@ -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>LUCENE_43</luceneMatchVersion>
|
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- lib directives can be used to instruct Solr to load an Jars
|
<!-- lib directives can be used to instruct Solr to load an 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>LUCENE_43</luceneMatchVersion>
|
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load an Jars
|
<!-- <lib/> directives can be used to instruct Solr to load an 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>LUCENE_43</luceneMatchVersion>
|
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load an Jars
|
<!-- <lib/> directives can be used to instruct Solr to load an 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>LUCENE_43</luceneMatchVersion>
|
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- lib directives can be used to instruct Solr to load an Jars
|
<!-- lib directives can be used to instruct Solr to load an 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>LUCENE_43</luceneMatchVersion>
|
<luceneMatchVersion>${tests.luceneMatchVersion:LUCENE_CURRENT}</luceneMatchVersion>
|
||||||
|
|
||||||
<!-- <lib/> directives can be used to instruct Solr to load an Jars
|
<!-- <lib/> directives can be used to instruct Solr to load an Jars
|
||||||
identified and use them to resolve any "plugins" specified in
|
identified and use them to resolve any "plugins" specified in
|
||||||
|
|
|
@ -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_40.
|
// Old indexDefaults and mainIndex sections are deprecated and fails fast for luceneMatchVersion=>LUCENE_4_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_40)) {
|
if(luceneMatchVersion.onOrAfter(Version.LUCENE_4_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_40 and later. Please use <indexConfig> instead.");
|
log.warn("<indexDefaults> and <mainIndex> configuration sections are deprecated and will fail for luceneMatchVersion=LUCENE_4_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";
|
||||||
|
|
|
@ -407,7 +407,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_40)) {
|
if (!version.onOrAfter(Version.LUCENE_4_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");
|
||||||
|
|
|
@ -481,7 +481,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_47)) {
|
if (!luceneVersion.onOrAfter(Version.LUCENE_4_7)) {
|
||||||
similarityParams.add(DefaultSimilarityFactory.DISCOUNT_OVERLAPS, false);
|
similarityParams.add(DefaultSimilarityFactory.DISCOUNT_OVERLAPS, false);
|
||||||
}
|
}
|
||||||
similarityFactory.init(SolrParams.toSolrParams(similarityParams));
|
similarityFactory.init(SolrParams.toSolrParams(similarityParams));
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class SolrIndexConfig {
|
||||||
luceneVersion = solrConfig.luceneMatchVersion;
|
luceneVersion = solrConfig.luceneMatchVersion;
|
||||||
|
|
||||||
// Assert that end-of-life parameters or syntax is not in our config.
|
// Assert that end-of-life parameters or syntax is not in our config.
|
||||||
// Warn for luceneMatchVersion's before LUCENE_36, fail fast above
|
// Warn for luceneMatchVersion's before LUCENE_3_6, fail fast above
|
||||||
assertWarnOrFail("The <mergeScheduler>myclass</mergeScheduler> syntax is no longer supported in solrconfig.xml. Please use syntax <mergeScheduler class=\"myclass\"/> instead.",
|
assertWarnOrFail("The <mergeScheduler>myclass</mergeScheduler> syntax is no longer supported in solrconfig.xml. Please use syntax <mergeScheduler class=\"myclass\"/> instead.",
|
||||||
!((solrConfig.getNode(prefix+"/mergeScheduler",false) != null) && (solrConfig.get(prefix+"/mergeScheduler/@class",null) == null)),
|
!((solrConfig.getNode(prefix+"/mergeScheduler",false) != null) && (solrConfig.get(prefix+"/mergeScheduler/@class",null) == null)),
|
||||||
true);
|
true);
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
</analyzer>
|
</analyzer>
|
||||||
</fieldtype>
|
</fieldtype>
|
||||||
<fieldtype name="textStandardAnalyzer40" class="solr.TextField">
|
<fieldtype name="textStandardAnalyzer40" class="solr.TextField">
|
||||||
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer" luceneMatchVersion="LUCENE_40"/>
|
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer" luceneMatchVersion="LUCENE_4_0"/>
|
||||||
</fieldtype>
|
</fieldtype>
|
||||||
<fieldtype name="textStandardAnalyzerDefault" class="solr.TextField">
|
<fieldtype name="textStandardAnalyzerDefault" class="solr.TextField">
|
||||||
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
|
<analyzer class="org.apache.lucene.analysis.standard.StandardAnalyzer"/>
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
<fieldtype name="explicitLuceneMatchVersions" class="org.apache.solr.schema.TextField">
|
<fieldtype name="explicitLuceneMatchVersions" class="org.apache.solr.schema.TextField">
|
||||||
<analyzer>
|
<analyzer>
|
||||||
<charFilter class="org.apache.solr.analysis.MockCharFilterFactory" luceneMatchVersion="LUCENE_40" remainder="0"/>
|
<charFilter class="org.apache.solr.analysis.MockCharFilterFactory" luceneMatchVersion="LUCENE_40" remainder="0"/>
|
||||||
<tokenizer class="org.apache.solr.analysis.MockTokenizerFactory" luceneMatchVersion="LUCENE_40" />
|
<tokenizer class="org.apache.solr.analysis.MockTokenizerFactory" luceneMatchVersion="LUCENE_4_0" />
|
||||||
<filter class="org.apache.solr.analysis.MockTokenFilterFactory" luceneMatchVersion="LUCENE_40" stopset="empty"/>
|
<filter class="org.apache.solr.analysis.MockTokenFilterFactory" luceneMatchVersion="4.0" stopset="empty"/>
|
||||||
</analyzer>
|
</analyzer>
|
||||||
</fieldtype>
|
</fieldtype>
|
||||||
<fieldtype name="noLuceneMatchVersions" class="org.apache.solr.schema.TextField">
|
<fieldtype name="noLuceneMatchVersions" class="org.apache.solr.schema.TextField">
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
discovery-based core configuration. Trying a minimal configuration to cut down the setup time.
|
discovery-based core configuration. Trying a minimal configuration to cut down the setup time.
|
||||||
use in conjunction with schema-minimal.xml perhaps? -->
|
use in conjunction with schema-minimal.xml perhaps? -->
|
||||||
<config>
|
<config>
|
||||||
<luceneMatchVersion>LUCENE_41</luceneMatchVersion>
|
<luceneMatchVersion>LUCENE_4_1</luceneMatchVersion>
|
||||||
|
|
||||||
<dataDir>${solr.data.dir:}</dataDir>
|
<dataDir>${solr.data.dir:}</dataDir>
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,8 @@ public class TestLuceneMatchVersion extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
type = schema.getFieldType("text40");
|
type = schema.getFieldType("text40");
|
||||||
ana = (TokenizerChain) type.getAnalyzer();
|
ana = (TokenizerChain) type.getAnalyzer();
|
||||||
assertEquals(Version.LUCENE_40, (ana.getTokenizerFactory()).getLuceneMatchVersion());
|
assertEquals(Version.LUCENE_4_0, (ana.getTokenizerFactory()).getLuceneMatchVersion());
|
||||||
assertEquals(Version.LUCENE_50, (ana.getTokenFilterFactories()[2]).getLuceneMatchVersion());
|
assertEquals(Version.LUCENE_5_0, (ana.getTokenFilterFactories()[2]).getLuceneMatchVersion());
|
||||||
|
|
||||||
// this is a hack to get the private matchVersion field in StandardAnalyzer's superclass, may break in later lucene versions - we have no getter :(
|
// this is a hack to get the private matchVersion field in StandardAnalyzer's superclass, may break in later lucene versions - we have no getter :(
|
||||||
final Field matchVersionField = StandardAnalyzer.class.getSuperclass().getDeclaredField("matchVersion");
|
final Field matchVersionField = StandardAnalyzer.class.getSuperclass().getDeclaredField("matchVersion");
|
||||||
|
@ -68,6 +68,6 @@ public class TestLuceneMatchVersion extends SolrTestCaseJ4 {
|
||||||
type = schema.getFieldType("textStandardAnalyzer40");
|
type = schema.getFieldType("textStandardAnalyzer40");
|
||||||
ana1 = type.getAnalyzer();
|
ana1 = type.getAnalyzer();
|
||||||
assertTrue(ana1 instanceof StandardAnalyzer);
|
assertTrue(ana1 instanceof StandardAnalyzer);
|
||||||
assertEquals(Version.LUCENE_40, matchVersionField.get(ana1));
|
assertEquals(Version.LUCENE_4_0, matchVersionField.get(ana1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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_40']]",
|
+" [str[@name='luceneMatchVersion'][.='LUCENE_4_0']]",
|
||||||
|
|
||||||
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenizerFactory']]"
|
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenizerFactory']]"
|
||||||
+" [str[@name='luceneMatchVersion'][.='LUCENE_40']]",
|
+" [str[@name='luceneMatchVersion'][.='LUCENE_4_0']]",
|
||||||
|
|
||||||
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenFilterFactory']]"
|
"//lst[str[@name='class'][.='org.apache.solr.analysis.MockTokenFilterFactory']]"
|
||||||
+" [str[@name='luceneMatchVersion'][.='LUCENE_40']]");
|
+" [str[@name='luceneMatchVersion'][.='LUCENE_4_0']]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -43,14 +43,14 @@ public class TestNonDefinedSimilarityFactory extends BaseSimilarityTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void test47() throws Exception {
|
public void test47() throws Exception {
|
||||||
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_47.toString());
|
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_4_7.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_46.toString());
|
System.setProperty("tests.luceneMatchVersion", Version.LUCENE_4_6.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());
|
||||||
|
|
Loading…
Reference in New Issue