mirror of https://github.com/apache/lucene.git
LUCENE-2245: Remaining contrib testcases should use Version based ctors instead of deprecated ones
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@907034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7f76eea086
commit
57d1387492
|
@ -79,7 +79,7 @@ public abstract class AbstractTestCase extends TestCase {
|
|||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
analyzerW = new WhitespaceAnalyzer();
|
||||
analyzerW = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
analyzerB = new BigramAnalyzer();
|
||||
paW = new QueryParser(Version.LUCENE_CURRENT, F, analyzerW );
|
||||
paB = new QueryParser(Version.LUCENE_CURRENT, F, analyzerB );
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.OpenBitSet;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class HighlighterPhraseTest extends TestCase {
|
|||
final String TEXT = "the fox jumped";
|
||||
final Directory directory = new RAMDirectory();
|
||||
final IndexWriter indexWriter = new IndexWriter(directory,
|
||||
new WhitespaceAnalyzer(), MaxFieldLength.UNLIMITED);
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT), MaxFieldLength.UNLIMITED);
|
||||
try {
|
||||
final Document document = new Document();
|
||||
document.add(new Field(FIELD, new TokenStreamConcurrent(),
|
||||
|
@ -103,7 +104,7 @@ public class HighlighterPhraseTest extends TestCase {
|
|||
final String TEXT = "the fox jumped";
|
||||
final Directory directory = new RAMDirectory();
|
||||
final IndexWriter indexWriter = new IndexWriter(directory,
|
||||
new WhitespaceAnalyzer(), MaxFieldLength.UNLIMITED);
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT), MaxFieldLength.UNLIMITED);
|
||||
try {
|
||||
final Document document = new Document();
|
||||
document.add(new Field(FIELD, new TokenStreamConcurrent(),
|
||||
|
@ -168,7 +169,7 @@ public class HighlighterPhraseTest extends TestCase {
|
|||
final String TEXT = "the fox did not jump";
|
||||
final Directory directory = new RAMDirectory();
|
||||
final IndexWriter indexWriter = new IndexWriter(directory,
|
||||
new WhitespaceAnalyzer(), MaxFieldLength.UNLIMITED);
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT), MaxFieldLength.UNLIMITED);
|
||||
try {
|
||||
final Document document = new Document();
|
||||
document.add(new Field(FIELD, new TokenStreamSparse(),
|
||||
|
@ -210,7 +211,7 @@ public class HighlighterPhraseTest extends TestCase {
|
|||
final String TEXT = "the fox did not jump";
|
||||
final Directory directory = new RAMDirectory();
|
||||
final IndexWriter indexWriter = new IndexWriter(directory,
|
||||
new WhitespaceAnalyzer(), MaxFieldLength.UNLIMITED);
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT), MaxFieldLength.UNLIMITED);
|
||||
try {
|
||||
final Document document = new Document();
|
||||
document.add(new Field(FIELD, TEXT, Store.YES, Index.ANALYZED,
|
||||
|
@ -250,7 +251,7 @@ public class HighlighterPhraseTest extends TestCase {
|
|||
final String TEXT = "the fox did not jump";
|
||||
final Directory directory = new RAMDirectory();
|
||||
final IndexWriter indexWriter = new IndexWriter(directory,
|
||||
new WhitespaceAnalyzer(), MaxFieldLength.UNLIMITED);
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT), MaxFieldLength.UNLIMITED);
|
||||
try {
|
||||
final Document document = new Document();
|
||||
document.add(new Field(FIELD, new TokenStreamSparse(),
|
||||
|
|
|
@ -118,7 +118,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
|
|||
}
|
||||
|
||||
public void testQueryScorerHits() throws Exception {
|
||||
Analyzer analyzer = new SimpleAnalyzer();
|
||||
Analyzer analyzer = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
QueryParser qp = new QueryParser(TEST_VERSION, FIELD_NAME, analyzer);
|
||||
query = qp.parse("\"very long\"");
|
||||
searcher = new IndexSearcher(ramDir, true);
|
||||
|
@ -226,7 +226,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
|
|||
String f2c = f2 + ":";
|
||||
String q = "(" + f1c + ph1 + " OR " + f2c + ph1 + ") AND (" + f1c + ph2
|
||||
+ " OR " + f2c + ph2 + ")";
|
||||
Analyzer analyzer = new WhitespaceAnalyzer();
|
||||
Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
QueryParser qp = new QueryParser(TEST_VERSION, f1, analyzer);
|
||||
Query query = qp.parse(q);
|
||||
|
||||
|
@ -1529,64 +1529,64 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
|
|||
Highlighter highlighter;
|
||||
String result;
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("foo");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("foo");
|
||||
highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2(), s, 3, "...");
|
||||
assertEquals("Hi-Speed10 <B>foo</B>", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("10");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("10");
|
||||
highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2(), s, 3, "...");
|
||||
assertEquals("Hi-Speed<B>10</B> foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("hi");
|
||||
highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2(), s, 3, "...");
|
||||
assertEquals("<B>Hi</B>-Speed10 foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("speed");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("speed");
|
||||
highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2(), s, 3, "...");
|
||||
assertEquals("Hi-<B>Speed</B>10 foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hispeed");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("hispeed");
|
||||
highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2(), s, 3, "...");
|
||||
assertEquals("<B>Hi-Speed</B>10 foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi speed");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("hi speed");
|
||||
highlighter = getHighlighter(query, "text", getTS2(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2(), s, 3, "...");
|
||||
assertEquals("<B>Hi-Speed</B>10 foo", result);
|
||||
|
||||
// ///////////////// same tests, just put the bigger overlapping token
|
||||
// first
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("foo");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("foo");
|
||||
highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
|
||||
assertEquals("Hi-Speed10 <B>foo</B>", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("10");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("10");
|
||||
highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
|
||||
assertEquals("Hi-Speed<B>10</B> foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("hi");
|
||||
highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
|
||||
assertEquals("<B>Hi</B>-Speed10 foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("speed");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("speed");
|
||||
highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
|
||||
assertEquals("Hi-<B>Speed</B>10 foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hispeed");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("hispeed");
|
||||
highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
|
||||
assertEquals("<B>Hi-Speed</B>10 foo", result);
|
||||
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer()).parse("hi speed");
|
||||
query = new QueryParser(TEST_VERSION, "text", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("hi speed");
|
||||
highlighter = getHighlighter(query, "text", getTS2a(), HighlighterTest.this);
|
||||
result = highlighter.getBestFragments(getTS2a(), s, 3, "...");
|
||||
assertEquals("<B>Hi-Speed</B>10 foo", result);
|
||||
|
@ -1597,7 +1597,7 @@ public class HighlighterTest extends BaseTokenStreamTestCase implements Formatte
|
|||
}
|
||||
|
||||
private Directory dir = new RAMDirectory();
|
||||
private Analyzer a = new WhitespaceAnalyzer();
|
||||
private Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
public void testWeightedTermsWithDeletes() throws IOException, ParseException, InvalidTokenOffsetsException {
|
||||
makeIndex();
|
||||
|
@ -1801,7 +1801,7 @@ class SynonymAnalyzer extends Analyzer {
|
|||
*/
|
||||
@Override
|
||||
public TokenStream tokenStream(String arg0, Reader arg1) {
|
||||
LowerCaseTokenizer stream = new LowerCaseTokenizer(arg1);
|
||||
LowerCaseTokenizer stream = new LowerCaseTokenizer(Version.LUCENE_CURRENT, arg1);
|
||||
stream.addAttribute(TermAttribute.class);
|
||||
stream.addAttribute(PositionIncrementAttribute.class);
|
||||
stream.addAttribute(OffsetAttribute.class);
|
||||
|
|
|
@ -20,6 +20,7 @@ package org.apache.lucene.store.instantiated;
|
|||
import junit.framework.TestCase;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.analysis.WhitespaceAnalyzer;
|
||||
|
@ -35,7 +36,7 @@ public class TestSerialization extends TestCase {
|
|||
|
||||
Directory dir = new RAMDirectory();
|
||||
|
||||
IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("foo", "bar rab abr bra rba", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
|
||||
doc.add(new Field("moo", "bar rab abr bra rba", Field.Store.YES, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS_OFFSETS));
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.analysis.WhitespaceAnalyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
|
@ -35,17 +36,17 @@ public class TestUnoptimizedReaderOnConstructor extends TestCase {
|
|||
|
||||
public void test() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter iw = new IndexWriter(dir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
addDocument(iw, "Hello, world!");
|
||||
addDocument(iw, "All work and no play makes jack a dull boy");
|
||||
iw.close();
|
||||
|
||||
iw = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
iw = new IndexWriter(dir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
addDocument(iw, "Hello, tellus!");
|
||||
addDocument(iw, "All work and no play makes danny a dull boy");
|
||||
iw.close();
|
||||
|
||||
iw = new IndexWriter(dir, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
iw = new IndexWriter(dir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
addDocument(iw, "Hello, earth!");
|
||||
addDocument(iw, "All work and no play makes wendy a dull girl");
|
||||
iw.close();
|
||||
|
|
|
@ -277,10 +277,10 @@ public class MemoryIndexTest extends BaseTokenStreamTestCase {
|
|||
Set<?> stopWords = StopAnalyzer.ENGLISH_STOP_WORDS_SET;
|
||||
|
||||
Analyzer[] analyzers = new Analyzer[] {
|
||||
new SimpleAnalyzer(),
|
||||
new SimpleAnalyzer(Version.LUCENE_CURRENT),
|
||||
new StopAnalyzer(Version.LUCENE_CURRENT),
|
||||
new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT),
|
||||
// new WhitespaceAnalyzer(),
|
||||
// new WhitespaceAnalyzer(Version.LUCENE_CURRENT),
|
||||
// new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, false, null),
|
||||
// new PatternAnalyzer(PatternAnalyzer.NON_WORD_PATTERN, true, stopWords),
|
||||
// new SnowballAnalyzer("English", StopAnalyzer.ENGLISH_STOP_WORDS),
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.apache.lucene.search.Similarity;
|
|||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
/**
|
||||
* Tests changing of field norms with a custom similarity and with fake norms.
|
||||
|
@ -57,7 +58,7 @@ public class TestFieldNormModifier extends TestCase {
|
|||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true, MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(Version.LUCENE_CURRENT), true, MaxFieldLength.UNLIMITED);
|
||||
|
||||
for (int i = 0; i < NUM_DOCS; i++) {
|
||||
Document d = new Document();
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
|
||||
import org.apache.lucene.store.FSDirectory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
public class TestIndexSplitter extends LuceneTestCase {
|
||||
|
@ -35,7 +36,7 @@ public class TestIndexSplitter extends LuceneTestCase {
|
|||
_TestUtil.rmDir(destDir);
|
||||
destDir.mkdirs();
|
||||
FSDirectory fsDir = FSDirectory.open(dir);
|
||||
IndexWriter iw = new IndexWriter(fsDir, new WhitespaceAnalyzer(), true, MaxFieldLength.UNLIMITED);
|
||||
IndexWriter iw = new IndexWriter(fsDir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, MaxFieldLength.UNLIMITED);
|
||||
for (int x=0; x < 100; x++) {
|
||||
Document doc = TestIndexWriterReader.createDocument(x, "index", 5);
|
||||
iw.addDocument(doc);
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.lucene.document.Field;
|
|||
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
@ -32,7 +33,7 @@ public class TestMultiPassIndexSplitter extends TestCase {
|
|||
@Override
|
||||
public void setUp() throws Exception {
|
||||
RAMDirectory dir = new RAMDirectory();
|
||||
IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(), true,
|
||||
IndexWriter w = new IndexWriter(dir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
MaxFieldLength.LIMITED);
|
||||
Document doc;
|
||||
for (int i = 0; i < NUM_DOCS; i++) {
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.apache.lucene.search.TermRangeFilter;
|
|||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
public class ChainedFilterTest extends TestCase {
|
||||
public static final int MAX = 500;
|
||||
|
@ -59,7 +60,7 @@ public class ChainedFilterTest extends TestCase {
|
|||
public void setUp() throws Exception {
|
||||
directory = new RAMDirectory();
|
||||
IndexWriter writer =
|
||||
new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
|
||||
Calendar cal = new GregorianCalendar();
|
||||
cal.clear();
|
||||
|
@ -187,7 +188,7 @@ public class ChainedFilterTest extends TestCase {
|
|||
|
||||
public void testWithCachingFilter() throws Exception {
|
||||
Directory dir = new RAMDirectory();
|
||||
Analyzer analyzer = new WhitespaceAnalyzer();
|
||||
Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
IndexWriter writer = new IndexWriter(dir, analyzer, true, MaxFieldLength.LIMITED);
|
||||
writer.close();
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.lucene.search.Similarity;
|
|||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
/**
|
||||
* Tests changing the norms after changing the simularity
|
||||
|
@ -60,7 +61,7 @@ public class TestLengthNormModifier extends TestCase {
|
|||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(), true, MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(store, new SimpleAnalyzer(Version.LUCENE_CURRENT), true, MaxFieldLength.UNLIMITED);
|
||||
|
||||
for (int i = 0; i < NUM_DOCS; i++) {
|
||||
Document d = new Document();
|
||||
|
|
|
@ -47,7 +47,7 @@ public class TestExtendableQueryParser extends TestQueryParser {
|
|||
public QueryParser getParser(Analyzer a, Extensions extensions)
|
||||
throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
QueryParser qp = extensions == null ? new ExtendableQueryParser(
|
||||
Version.LUCENE_CURRENT, "field", a) : new ExtendableQueryParser(
|
||||
Version.LUCENE_CURRENT, "field", a, extensions);
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.lucene.search.TermRangeQuery;
|
|||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.WildcardQuery;
|
||||
import org.apache.lucene.util.LocalizedTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
@ -99,7 +100,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
/** Filters LowerCaseTokenizer with StopFilter. */
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new QPTestFilter(new LowerCaseTokenizer(reader));
|
||||
return new QPTestFilter(new LowerCaseTokenizer(Version.LUCENE_CURRENT, reader));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
|
||||
public PrecedenceQueryParser getParser(Analyzer a) throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
PrecedenceQueryParser qp = new PrecedenceQueryParser("field", a);
|
||||
qp.setDefaultOperator(PrecedenceQueryParser.OR_OPERATOR);
|
||||
return qp;
|
||||
|
@ -174,7 +175,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
public Query getQueryDOA(String query, Analyzer a)
|
||||
throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
PrecedenceQueryParser qp = new PrecedenceQueryParser("field", a);
|
||||
qp.setDefaultOperator(PrecedenceQueryParser.AND_OPERATOR);
|
||||
return qp.parse(query);
|
||||
|
@ -254,7 +255,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testPunct() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
assertQueryEquals("a&b", a, "a&b");
|
||||
assertQueryEquals("a&&b", a, "a&&b");
|
||||
assertQueryEquals(".NET", a, ".NET");
|
||||
|
@ -412,7 +413,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testEscaped() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
/*assertQueryEquals("\\[brackets", a, "\\[brackets");
|
||||
assertQueryEquals("\\[brackets", null, "brackets");
|
||||
|
@ -544,7 +545,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
|
||||
public void testCustomQueryParserWildcard() {
|
||||
try {
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer()).parse("a?t");
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("a?t");
|
||||
} catch (ParseException expected) {
|
||||
return;
|
||||
}
|
||||
|
@ -553,7 +554,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
|
||||
public void testCustomQueryParserFuzzy() throws Exception {
|
||||
try {
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer()).parse("xunit~");
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("xunit~");
|
||||
} catch (ParseException expected) {
|
||||
return;
|
||||
}
|
||||
|
@ -563,7 +564,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
public void testBooleanQuery() throws Exception {
|
||||
BooleanQuery.setMaxClauseCount(2);
|
||||
try {
|
||||
getParser(new WhitespaceAnalyzer()).parse("one two three");
|
||||
getParser(new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("one two three");
|
||||
fail("ParseException expected due to too many boolean clauses");
|
||||
} catch (ParseException expected) {
|
||||
// too many boolean clauses, so ParseException is expected
|
||||
|
@ -577,7 +578,7 @@ public class TestPrecedenceQueryParser extends LocalizedTestCase {
|
|||
// failing tests disabled since PrecedenceQueryParser
|
||||
// is currently unmaintained
|
||||
public void _testPrecedence() throws Exception {
|
||||
PrecedenceQueryParser parser = getParser(new WhitespaceAnalyzer());
|
||||
PrecedenceQueryParser parser = getParser(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
Query query1 = parser.parse("A AND B OR C AND D");
|
||||
Query query2 = parser.parse("(A AND B) OR (C AND D)");
|
||||
assertEquals(query1, query2);
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
public class BooleanFilterTest extends TestCase
|
||||
{
|
||||
|
@ -38,7 +39,7 @@ public class BooleanFilterTest extends TestCase
|
|||
protected void setUp() throws Exception
|
||||
{
|
||||
directory = new RAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
|
||||
//Add series of docs with filterable fields : acces rights, prices, dates and "in-stock" flags
|
||||
addDoc(writer, "admin guest", "010", "20040101","Y");
|
||||
|
|
|
@ -30,12 +30,13 @@ import org.apache.lucene.index.IndexWriter;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
public class FuzzyLikeThisQueryTest extends TestCase
|
||||
{
|
||||
private RAMDirectory directory;
|
||||
private IndexSearcher searcher;
|
||||
private Analyzer analyzer=new WhitespaceAnalyzer();
|
||||
private Analyzer analyzer=new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
|
@ -114,7 +115,7 @@ public class FuzzyLikeThisQueryTest extends TestCase
|
|||
}
|
||||
|
||||
public void testFuzzyLikeThisQueryEquals() {
|
||||
Analyzer analyzer = new WhitespaceAnalyzer();
|
||||
Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
FuzzyLikeThisQuery fltq1 = new FuzzyLikeThisQuery(10, analyzer);
|
||||
fltq1.addTerms("javi", "subject", 0.5f, 2);
|
||||
FuzzyLikeThisQuery fltq2 = new FuzzyLikeThisQuery(10, analyzer);
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.lucene.index.Term;
|
|||
import org.apache.lucene.index.IndexWriter.MaxFieldLength;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.OpenBitSet;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
public class TermsFilterTest extends TestCase
|
||||
{
|
||||
|
@ -55,7 +56,7 @@ public class TermsFilterTest extends TestCase
|
|||
{
|
||||
String fieldName="field1";
|
||||
RAMDirectory rd=new RAMDirectory();
|
||||
IndexWriter w=new IndexWriter(rd,new WhitespaceAnalyzer(),MaxFieldLength.UNLIMITED);
|
||||
IndexWriter w=new IndexWriter(rd,new WhitespaceAnalyzer(Version.LUCENE_CURRENT),MaxFieldLength.UNLIMITED);
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
Document doc=new Document();
|
||||
|
|
|
@ -144,7 +144,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
/** Filters LowerCaseTokenizer with StopFilter. */
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new QPTestFilter(new LowerCaseTokenizer(reader));
|
||||
return new QPTestFilter(new LowerCaseTokenizer(Version.LUCENE_CURRENT, reader));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
|
||||
public StandardQueryParser getParser(Analyzer a) throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(a);
|
||||
|
||||
|
@ -294,7 +294,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
|
||||
public Query getQueryDOA(String query, Analyzer a) throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(a);
|
||||
qp.setDefaultOperator(Operator.AND);
|
||||
|
@ -314,7 +314,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testConstantScoreAutoRewrite() throws Exception {
|
||||
StandardQueryParser qp = new StandardQueryParser(new WhitespaceAnalyzer());
|
||||
StandardQueryParser qp = new StandardQueryParser(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
Query q = qp.parse("foo*bar", "field");
|
||||
assertTrue(q instanceof WildcardQuery);
|
||||
assertEquals(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, ((MultiTermQuery) q).getRewriteMethod());
|
||||
|
@ -339,9 +339,9 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
public void testSimple() throws Exception {
|
||||
assertQueryEquals("\"term germ\"~2", null, "\"term germ\"~2");
|
||||
assertQueryEquals("term term term", null, "term term term");
|
||||
assertQueryEquals("t<EFBFBD>rm term term", new WhitespaceAnalyzer(),
|
||||
assertQueryEquals("t<EFBFBD>rm term term", new WhitespaceAnalyzer(Version.LUCENE_CURRENT),
|
||||
"t<EFBFBD>rm term term");
|
||||
assertQueryEquals("<EFBFBD>mlaut", new WhitespaceAnalyzer(), "<EFBFBD>mlaut");
|
||||
assertQueryEquals("<EFBFBD>mlaut", new WhitespaceAnalyzer(Version.LUCENE_CURRENT), "<EFBFBD>mlaut");
|
||||
|
||||
assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
|
||||
assertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");
|
||||
|
@ -398,7 +398,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testPunct() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
assertQueryEquals("a&b", a, "a&b");
|
||||
assertQueryEquals("a&&b", a, "a&&b");
|
||||
assertQueryEquals(".NET", a, ".NET");
|
||||
|
@ -573,7 +573,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
public void testFarsiRangeCollating() throws Exception {
|
||||
|
||||
RAMDirectory ramDir = new RAMDirectory();
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true,
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
IndexWriter.MaxFieldLength.LIMITED);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
|
||||
|
@ -583,7 +583,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
IndexSearcher is = new IndexSearcher(ramDir, true);
|
||||
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer());
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
// Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
|
||||
// RuleBasedCollator. However, the Arabic Locale seems to order the
|
||||
|
@ -737,7 +737,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testEscaped() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
/*
|
||||
* assertQueryEquals("\\[brackets", a, "\\[brackets");
|
||||
|
@ -836,7 +836,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testQueryStringEscaping() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
assertEscapedQueryEquals("a-b:c", a, "a\\-b\\:c");
|
||||
assertEscapedQueryEquals("a+b:c", a, "a\\+b\\:c");
|
||||
|
@ -951,7 +951,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
|
||||
public void testCustomQueryParserWildcard() {
|
||||
try {
|
||||
new QPTestParser(new WhitespaceAnalyzer()).parse("a?t", "contents");
|
||||
new QPTestParser(new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("a?t", "contents");
|
||||
fail("Wildcard queries should not be allowed");
|
||||
} catch (QueryNodeException expected) {
|
||||
// expected exception
|
||||
|
@ -960,7 +960,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
|
||||
public void testCustomQueryParserFuzzy() throws Exception {
|
||||
try {
|
||||
new QPTestParser(new WhitespaceAnalyzer()).parse("xunit~", "contents");
|
||||
new QPTestParser(new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("xunit~", "contents");
|
||||
fail("Fuzzy queries should not be allowed");
|
||||
} catch (QueryNodeException expected) {
|
||||
// expected exception
|
||||
|
@ -971,7 +971,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
BooleanQuery.setMaxClauseCount(2);
|
||||
try {
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer());
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
qp.parse("one two three", "field");
|
||||
fail("ParseException expected due to too many boolean clauses");
|
||||
|
@ -985,7 +985,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
*/
|
||||
public void testPrecedence() throws Exception {
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer());
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
Query query1 = qp.parse("A AND B OR C AND D", "field");
|
||||
Query query2 = qp.parse("+A +B +C +D", "field");
|
||||
|
@ -996,7 +996,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
public void testLocalDateFormat() throws IOException, QueryNodeException {
|
||||
|
||||
RAMDirectory ramDir = new RAMDirectory();
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true,
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
IndexWriter.MaxFieldLength.LIMITED);
|
||||
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
|
||||
addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);
|
||||
|
@ -1121,7 +1121,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
|
||||
public void testMatchAllDocs() throws Exception {
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer());
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
assertEquals(new MatchAllDocsQuery(), qp.parse("*:*", "field"));
|
||||
assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)", "field"));
|
||||
|
@ -1133,7 +1133,7 @@ public class TestQPHelper extends LocalizedTestCase {
|
|||
private void assertHits(int expected, String query, IndexSearcher is)
|
||||
throws IOException, QueryNodeException {
|
||||
StandardQueryParser qp = new StandardQueryParser();
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer());
|
||||
qp.setAnalyzer(new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
qp.setLocale(Locale.ENGLISH);
|
||||
|
||||
Query q = qp.parse(query, "date");
|
||||
|
|
|
@ -139,7 +139,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
/** Filters LowerCaseTokenizer with StopFilter. */
|
||||
@Override
|
||||
public final TokenStream tokenStream(String fieldName, Reader reader) {
|
||||
return new QPTestFilter(new LowerCaseTokenizer(reader));
|
||||
return new QPTestFilter(new LowerCaseTokenizer(Version.LUCENE_CURRENT, reader));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
|
||||
public QueryParserWrapper getParser(Analyzer a) throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field", a);
|
||||
qp.setDefaultOperator(QueryParserWrapper.OR_OPERATOR);
|
||||
return qp;
|
||||
|
@ -302,7 +302,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
|
||||
public Query getQueryDOA(String query, Analyzer a) throws Exception {
|
||||
if (a == null)
|
||||
a = new SimpleAnalyzer();
|
||||
a = new SimpleAnalyzer(Version.LUCENE_CURRENT);
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field", a);
|
||||
qp.setDefaultOperator(QueryParserWrapper.AND_OPERATOR);
|
||||
return qp.parse(query);
|
||||
|
@ -329,9 +329,9 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
public void testSimple() throws Exception {
|
||||
assertQueryEquals("\"term germ\"~2", null, "\"term germ\"~2");
|
||||
assertQueryEquals("term term term", null, "term term term");
|
||||
assertQueryEquals("t<EFBFBD>rm term term", new WhitespaceAnalyzer(),
|
||||
assertQueryEquals("t<EFBFBD>rm term term", new WhitespaceAnalyzer(Version.LUCENE_CURRENT),
|
||||
"t<EFBFBD>rm term term");
|
||||
assertQueryEquals("<EFBFBD>mlaut", new WhitespaceAnalyzer(), "<EFBFBD>mlaut");
|
||||
assertQueryEquals("<EFBFBD>mlaut", new WhitespaceAnalyzer(Version.LUCENE_CURRENT), "<EFBFBD>mlaut");
|
||||
|
||||
assertQueryEquals("\"\"", new KeywordAnalyzer(), "");
|
||||
assertQueryEquals("foo:\"\"", new KeywordAnalyzer(), "foo:");
|
||||
|
@ -396,7 +396,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testPunct() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
assertQueryEquals("a&b", a, "a&b");
|
||||
assertQueryEquals("a&&b", a, "a&&b");
|
||||
assertQueryEquals(".NET", a, ".NET");
|
||||
|
@ -552,7 +552,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
assertEquals(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, ((TermRangeQuery)getQuery("[ a TO z]", null)).getRewriteMethod());
|
||||
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field",
|
||||
new SimpleAnalyzer());
|
||||
new SimpleAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
qp.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
|
||||
assertEquals(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE,((TermRangeQuery)qp.parse("[ a TO z]")).getRewriteMethod());
|
||||
|
@ -571,7 +571,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
public void testFarsiRangeCollating() throws Exception {
|
||||
|
||||
RAMDirectory ramDir = new RAMDirectory();
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true,
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
IndexWriter.MaxFieldLength.LIMITED);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES,
|
||||
|
@ -581,7 +581,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
IndexSearcher is = new IndexSearcher(ramDir, true);
|
||||
|
||||
QueryParserWrapper qp = new QueryParserWrapper("content",
|
||||
new WhitespaceAnalyzer());
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
// Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
|
||||
// RuleBasedCollator. However, the Arabic Locale seems to order the Farsi
|
||||
|
@ -683,7 +683,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
final String monthField = "month";
|
||||
final String hourField = "hour";
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field",
|
||||
new SimpleAnalyzer());
|
||||
new SimpleAnalyzer(Version.LUCENE_CURRENT));
|
||||
|
||||
// Don't set any date resolution and verify if DateField is used
|
||||
assertDateRangeQueryEquals(qp, defaultField, startDate, endDate,
|
||||
|
@ -727,7 +727,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testEscaped() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
/*
|
||||
* assertQueryEquals("\\[brackets", a, "\\[brackets");
|
||||
|
@ -824,7 +824,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
}
|
||||
|
||||
public void testQueryStringEscaping() throws Exception {
|
||||
Analyzer a = new WhitespaceAnalyzer();
|
||||
Analyzer a = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);
|
||||
|
||||
assertEscapedQueryEquals("a-b:c", a, "a\\-b\\:c");
|
||||
assertEscapedQueryEquals("a+b:c", a, "a\\+b\\:c");
|
||||
|
@ -935,7 +935,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
|
||||
public void testCustomQueryParserWildcard() {
|
||||
try {
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer()).parse("a?t");
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("a?t");
|
||||
fail("Wildcard queries should not be allowed");
|
||||
} catch (ParseException expected) {
|
||||
// expected exception
|
||||
|
@ -944,7 +944,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
|
||||
public void testCustomQueryParserFuzzy() throws Exception {
|
||||
try {
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer()).parse("xunit~");
|
||||
new QPTestParser("contents", new WhitespaceAnalyzer(Version.LUCENE_CURRENT)).parse("xunit~");
|
||||
fail("Fuzzy queries should not be allowed");
|
||||
} catch (ParseException expected) {
|
||||
// expected exception
|
||||
|
@ -955,7 +955,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
BooleanQuery.setMaxClauseCount(2);
|
||||
try {
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field",
|
||||
new WhitespaceAnalyzer());
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
qp.parse("one two three");
|
||||
fail("ParseException expected due to too many boolean clauses");
|
||||
} catch (ParseException expected) {
|
||||
|
@ -968,7 +968,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
*/
|
||||
public void testPrecedence() throws Exception {
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field",
|
||||
new WhitespaceAnalyzer());
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
Query query1 = qp.parse("A AND B OR C AND D");
|
||||
Query query2 = qp.parse("+A +B +C +D");
|
||||
|
||||
|
@ -978,7 +978,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
public void testLocalDateFormat() throws IOException, ParseException {
|
||||
|
||||
RAMDirectory ramDir = new RAMDirectory();
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true,
|
||||
IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
IndexWriter.MaxFieldLength.LIMITED);
|
||||
addDateDoc("a", 2005, 12, 2, 10, 15, 33, iw);
|
||||
addDateDoc("b", 2005, 12, 4, 22, 15, 00, iw);
|
||||
|
@ -1095,7 +1095,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
|
||||
public void testMatchAllDocs() throws Exception {
|
||||
QueryParserWrapper qp = new QueryParserWrapper("field",
|
||||
new WhitespaceAnalyzer());
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
assertEquals(new MatchAllDocsQuery(), qp.parse("*:*"));
|
||||
assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)"));
|
||||
BooleanQuery bq = (BooleanQuery) qp.parse("+*:* -*:*");
|
||||
|
@ -1106,7 +1106,7 @@ public class TestQueryParserWrapper extends LocalizedTestCase {
|
|||
private void assertHits(int expected, String query, IndexSearcher is)
|
||||
throws ParseException, IOException {
|
||||
QueryParserWrapper qp = new QueryParserWrapper("date",
|
||||
new WhitespaceAnalyzer());
|
||||
new WhitespaceAnalyzer(Version.LUCENE_CURRENT));
|
||||
qp.setLocale(Locale.ENGLISH);
|
||||
Query q = qp.parse(query);
|
||||
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.lucene.index.TermEnum;
|
|||
|
||||
import org.apache.lucene.search.spans.SpanNearQuery;
|
||||
import org.apache.lucene.search.spans.SpanQuery;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
public class TestRegexQuery extends TestCase {
|
||||
private IndexSearcher searcher;
|
||||
|
@ -39,7 +40,7 @@ public class TestRegexQuery extends TestCase {
|
|||
public void setUp() {
|
||||
RAMDirectory directory = new RAMDirectory();
|
||||
try {
|
||||
IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true,
|
||||
IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
IndexWriter.MaxFieldLength.LIMITED);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field(FN, "the quick brown fox jumps over the lazy dog", Field.Store.NO, Field.Index.ANALYZED));
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.apache.lucene.search.spans.SpanQuery;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.LockObtainFailedException;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
public class TestSpanRegexQuery extends TestCase {
|
||||
Directory indexStoreA = new RAMDirectory();
|
||||
|
@ -44,7 +45,7 @@ public class TestSpanRegexQuery extends TestCase {
|
|||
|
||||
public void testSpanRegex() throws Exception {
|
||||
RAMDirectory directory = new RAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(directory, new SimpleAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
Document doc = new Document();
|
||||
// doc.add(new Field("field", "the quick brown fox jumps over the lazy dog",
|
||||
// Field.Store.NO, Field.Index.ANALYZED));
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.rmi.Naming;
|
|||
import java.rmi.registry.LocateRegistry;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
import org.apache.lucene.analysis.SimpleAnalyzer;
|
||||
|
@ -57,7 +58,7 @@ public class TestRemoteCachingWrapperFilter extends LuceneTestCase {
|
|||
private static void startServer() throws Exception {
|
||||
// construct an index
|
||||
RAMDirectory indexStore = new RAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(), true,
|
||||
IndexWriter writer = new IndexWriter(indexStore, new SimpleAnalyzer(Version.LUCENE_CURRENT), true,
|
||||
IndexWriter.MaxFieldLength.LIMITED);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.lucene.search;
|
|||
*/
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.analysis.SimpleAnalyzer;
|
||||
import org.apache.lucene.document.*;
|
||||
|
@ -58,7 +59,7 @@ public class TestRemoteSearchable extends LuceneTestCase {
|
|||
private static void startServer() throws Exception {
|
||||
// construct an index
|
||||
RAMDirectory indexStore = new RAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(indexStore,new SimpleAnalyzer(),true, IndexWriter.MaxFieldLength.LIMITED);
|
||||
IndexWriter writer = new IndexWriter(indexStore,new SimpleAnalyzer(Version.LUCENE_CURRENT),true, IndexWriter.MaxFieldLength.LIMITED);
|
||||
Document doc = new Document();
|
||||
doc.add(new Field("test", "test text", Field.Store.YES, Field.Index.ANALYZED));
|
||||
doc.add(new Field("other", "other test text", Field.Store.YES, Field.Index.ANALYZED));
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.lucene.index.IndexWriter;
|
|||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
|
||||
/**
|
||||
|
@ -109,7 +110,7 @@ public class TestRemoteSort extends LuceneTestCase implements Serializable {
|
|||
private Searcher getIndex (boolean even, boolean odd)
|
||||
throws IOException {
|
||||
RAMDirectory indexStore = new RAMDirectory ();
|
||||
IndexWriter writer = new IndexWriter (indexStore, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
|
||||
IndexWriter writer = new IndexWriter (indexStore, new SimpleAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
|
||||
writer.setMaxBufferedDocs(2);
|
||||
writer.setMergeFactor(1000);
|
||||
for (int i=0; i<data.length; ++i) {
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.apache.lucene.spatial.tier.projections.SinusoidalProjector;
|
|||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -76,7 +77,7 @@ public class TestCartesian extends TestCase{
|
|||
protected void setUp() throws IOException {
|
||||
directory = new RAMDirectory();
|
||||
|
||||
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
|
||||
setUpPlotter( 2, 15);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.search.QueryWrapperFilter;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.lucene.util.NumericUtils;
|
||||
import org.apache.lucene.util.Version;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
|
||||
|
||||
|
@ -49,7 +50,7 @@ public class TestDistance extends TestCase{
|
|||
@Override
|
||||
protected void setUp() throws IOException {
|
||||
directory = new RAMDirectory();
|
||||
writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
writer = new IndexWriter(directory, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
addData(writer);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.lucene.index.IndexReader;
|
|||
import org.apache.lucene.index.IndexWriter;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
/**
|
||||
* Test case for LuceneDictionary.
|
||||
|
@ -48,7 +49,7 @@ public class TestLuceneDictionary extends TestCase {
|
|||
@Override
|
||||
public void setUp() throws Exception {
|
||||
|
||||
IndexWriter writer = new IndexWriter(store, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(store, new WhitespaceAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
|
||||
Document doc;
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.apache.lucene.store.Directory;
|
|||
import org.apache.lucene.store.RAMDirectory;
|
||||
import org.apache.lucene.util.English;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -57,7 +58,7 @@ public class TestSpellChecker extends LuceneTestCase {
|
|||
|
||||
//create a user index
|
||||
userindex = new RAMDirectory();
|
||||
IndexWriter writer = new IndexWriter(userindex, new SimpleAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
IndexWriter writer = new IndexWriter(userindex, new SimpleAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.UNLIMITED);
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
Document doc = new Document();
|
||||
|
|
Loading…
Reference in New Issue