You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@lucene.apache.org by ma...@apache.org on 2009/10/29 02:00:10 UTC
svn commit: r830815 [2/2] - in
/lucene/java/branches/flex_1458_2_9_back_compat_tests: ./
src/java/org/apache/lucene/analysis/
src/java/org/apache/lucene/analysis/standard/
src/java/org/apache/lucene/queryParser/ src/java/org/apache/lucene/util/
src/tes...
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestParallelReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestParallelReader.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestParallelReader.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/index/TestParallelReader.java Thu Oct 29 01:00:08 2009
@@ -105,7 +105,7 @@
// one document only:
Directory dir2 = new MockRAMDirectory();
- IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
w2.addDocument(d3);
@@ -150,13 +150,13 @@
Directory dir2 = getDir2();
// add another document to ensure that the indexes are not optimized
- IndexWriter modifier = new IndexWriter(dir1, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter modifier = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
Document d = new Document();
d.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
modifier.addDocument(d);
modifier.close();
- modifier = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
d = new Document();
d.add(new Field("f2", "v2", Field.Store.YES, Field.Index.ANALYZED));
modifier.addDocument(d);
@@ -169,7 +169,7 @@
assertFalse(pr.isOptimized());
pr.close();
- modifier = new IndexWriter(dir1, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.optimize();
modifier.close();
@@ -181,7 +181,7 @@
pr.close();
- modifier = new IndexWriter(dir2, new StandardAnalyzer(), IndexWriter.MaxFieldLength.LIMITED);
+ modifier = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), IndexWriter.MaxFieldLength.LIMITED);
modifier.optimize();
modifier.close();
@@ -232,7 +232,7 @@
// Fields 1-4 indexed together:
private Searcher single() throws IOException {
Directory dir = new MockRAMDirectory();
- IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d1 = new Document();
d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -262,7 +262,7 @@
private Directory getDir1() throws IOException {
Directory dir1 = new MockRAMDirectory();
- IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w1 = new IndexWriter(dir1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d1 = new Document();
d1.add(new Field("f1", "v1", Field.Store.YES, Field.Index.ANALYZED));
d1.add(new Field("f2", "v1", Field.Store.YES, Field.Index.ANALYZED));
@@ -277,7 +277,7 @@
private Directory getDir2() throws IOException {
Directory dir2 = new RAMDirectory();
- IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter w2 = new IndexWriter(dir2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
Document d3 = new Document();
d3.add(new Field("f3", "v1", Field.Store.YES, Field.Index.ANALYZED));
d3.add(new Field("f4", "v1", Field.Store.YES, Field.Index.ANALYZED));
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiAnalyzer.java Thu Oct 29 01:00:08 2009
@@ -31,6 +31,7 @@
import org.apache.lucene.analysis.tokenattributes.TypeAttribute;
import org.apache.lucene.search.Query;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.util.Version;
/**
* Test QueryParser's ability to deal with Analyzers that return more
@@ -44,7 +45,7 @@
public void testMultiAnalyzer() throws ParseException {
- QueryParser qp = new QueryParser("", new MultiAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "", new MultiAnalyzer());
// trivial, no multiple tokens:
assertEquals("foo", qp.parse("foo").toString());
@@ -117,7 +118,7 @@
}
public void testPosIncrementAnalyzer() throws ParseException {
- QueryParser qp = new QueryParser("", new PosIncrementAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_24, "", 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());
@@ -134,7 +135,7 @@
}
public TokenStream tokenStream(String fieldName, Reader reader) {
- TokenStream result = new StandardTokenizer(reader);
+ TokenStream result = new StandardTokenizer(Version.LUCENE_CURRENT, reader);
result = new TestFilter(result);
result = new LowerCaseFilter(result);
return result;
@@ -200,7 +201,7 @@
}
public TokenStream tokenStream(String fieldName, Reader reader) {
- TokenStream result = new StandardTokenizer(reader);
+ TokenStream result = new StandardTokenizer(Version.LUCENE_CURRENT, reader);
result = new TestPosIncrementFilter(result);
result = new LowerCaseFilter(result);
return result;
@@ -238,7 +239,7 @@
private final static class DumbQueryParser extends QueryParser {
public DumbQueryParser(String f, Analyzer a) {
- super(f, a);
+ super(Version.LUCENE_CURRENT, f, a);
}
/** expose super's version */
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java Thu Oct 29 01:00:08 2009
@@ -36,6 +36,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.analysis.BaseTokenStreamTestCase;
+import org.apache.lucene.util.Version;
/**
* Tests QueryParser.
@@ -59,18 +60,18 @@
String[] fields = {"b", "t"};
Occur occur[] = {Occur.SHOULD, Occur.SHOULD};
TestQueryParser.QPTestAnalyzer a = new TestQueryParser.QPTestAnalyzer();
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, a);
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, a);
Query q = mfqp.parse(qtxt);
assertEquals(expectedRes, q.toString());
- q = MultiFieldQueryParser.parse(qtxt, fields, occur, a);
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, qtxt, fields, occur, a);
assertEquals(expectedRes, q.toString());
}
public void testSimple() throws Exception {
String[] fields = {"b", "t"};
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query q = mfqp.parse("one");
assertEquals("b:one t:one", q.toString());
@@ -133,7 +134,7 @@
boosts.put("b", new Float(5));
boosts.put("t", new Float(10));
String[] fields = {"b", "t"};
- MultiFieldQueryParser mfqp = new MultiFieldQueryParser(fields, new StandardAnalyzer(), boosts);
+ MultiFieldQueryParser mfqp = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), boosts);
//Check for simple
@@ -159,24 +160,24 @@
public void testStaticMethod1() throws ParseException {
String[] fields = {"b", "t"};
String[] queries = {"one", "two"};
- Query q = MultiFieldQueryParser.parse(queries, fields, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one t:two", q.toString());
String[] queries2 = {"+one", "+two"};
- q = MultiFieldQueryParser.parse(queries2, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries2, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(+b:one) (+t:two)", q.toString());
String[] queries3 = {"one", "+two"};
- q = MultiFieldQueryParser.parse(queries3, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries3, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("b:one (+t:two)", q.toString());
String[] queries4 = {"one +more", "+two"};
- q = MultiFieldQueryParser.parse(queries4, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries4, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("(b:one +b:more) (+t:two)", q.toString());
String[] queries5 = {"blah"};
try {
- q = MultiFieldQueryParser.parse(queries5, fields, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries5, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -186,11 +187,11 @@
TestQueryParser.QPTestAnalyzer stopA = new TestQueryParser.QPTestAnalyzer();
String[] queries6 = {"((+stop))", "+((stop))"};
- q = MultiFieldQueryParser.parse(queries6, fields, stopA);
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries6, fields, stopA);
assertEquals("", q.toString());
String[] queries7 = {"one ((+stop)) +more", "+((stop)) +two"};
- q = MultiFieldQueryParser.parse(queries7, fields, stopA);
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries7, fields, stopA);
assertEquals("(b:one +b:more) (+t:two)", q.toString());
}
@@ -198,15 +199,15 @@
public void testStaticMethod2() throws ParseException {
String[] fields = {"b", "t"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "one", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:one", q.toString());
- q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "one two", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "blah", fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -217,17 +218,17 @@
String[] fields = {"b", "t"};
//int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new StandardAnalyzer());
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
- Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer());//, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "one", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));//, fields, flags, new StandardAnalyzer());
assertEquals("+b:one -t:one", q.toString());
- q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "one two", fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, "blah", fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -239,12 +240,12 @@
String[] fields = {"f1", "f2", "f3"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST,
BooleanClause.Occur.MUST_NOT, BooleanClause.Occur.SHOULD};
- Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries, fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+f1:one -f2:two f3:three", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries, fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -255,12 +256,12 @@
String[] queries = {"one", "two"};
String[] fields = {"b", "t"};
BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
- Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer());
+ Query q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries, fields, flags, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
assertEquals("+b:one -t:two", q.toString());
try {
BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
- q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer());
+ q = MultiFieldQueryParser.parse(Version.LUCENE_CURRENT, queries, fields, flags2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
fail();
} catch(IllegalArgumentException e) {
// expected exception, array length differs
@@ -269,7 +270,7 @@
public void testAnalyzerReturningNull() throws ParseException {
String[] fields = new String[] { "f1", "f2", "f3" };
- MultiFieldQueryParser parser = new MultiFieldQueryParser(fields, new AnalyzerReturningNull());
+ MultiFieldQueryParser parser = new MultiFieldQueryParser(Version.LUCENE_CURRENT, fields, new AnalyzerReturningNull());
Query q = parser.parse("bla AND blo");
assertEquals("+(f2:bla f3:bla) +(f2:blo f3:blo)", q.toString());
// the following queries are not affected as their terms are not analyzed anyway:
@@ -282,7 +283,7 @@
}
public void testStopWordSearching() throws Exception {
- Analyzer analyzer = new StandardAnalyzer();
+ Analyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
Directory ramDir = new RAMDirectory();
IndexWriter iw = new IndexWriter(ramDir, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -291,7 +292,7 @@
iw.close();
MultiFieldQueryParser mfqp =
- new MultiFieldQueryParser(new String[] {"body"}, analyzer);
+ new MultiFieldQueryParser(Version.LUCENE_CURRENT, new String[] {"body"}, analyzer);
mfqp.setDefaultOperator(QueryParser.Operator.AND);
Query q = mfqp.parse("the footest");
IndexSearcher is = new IndexSearcher(ramDir, true);
@@ -304,7 +305,7 @@
* Return empty tokens for field "f1".
*/
private static class AnalyzerReturningNull extends Analyzer {
- StandardAnalyzer stdAnalyzer = new StandardAnalyzer();
+ StandardAnalyzer stdAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
public AnalyzerReturningNull() {
}
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java Thu Oct 29 01:00:08 2009
@@ -47,6 +47,7 @@
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
+import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.MultiTermQuery;
import org.apache.lucene.search.FuzzyQuery;
@@ -60,7 +61,10 @@
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.WildcardQuery;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.MockRAMDirectory;
import org.apache.lucene.util.LocalizedTestCase;
+import org.apache.lucene.util.Version;
/**
* Tests QueryParser.
@@ -127,7 +131,7 @@
public static class QPTestParser extends QueryParser {
public QPTestParser(String f, Analyzer a) {
- super(f, a);
+ super(Version.LUCENE_CURRENT, f, a);
}
protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException {
@@ -149,7 +153,7 @@
public QueryParser getParser(Analyzer a) throws Exception {
if (a == null)
a = new SimpleAnalyzer();
- QueryParser qp = new QueryParser("field", a);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", a);
qp.setDefaultOperator(QueryParser.OR_OPERATOR);
return qp;
}
@@ -219,7 +223,7 @@
throws Exception {
if (a == null)
a = new SimpleAnalyzer();
- QueryParser qp = new QueryParser("field", a);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", a);
qp.setDefaultOperator(QueryParser.AND_OPERATOR);
return qp.parse(query);
}
@@ -291,7 +295,7 @@
assertQueryEquals("+title:(dog OR cat) -author:\"bob dole\"", null,
"+(title:dog title:cat) -author:\"bob dole\"");
- QueryParser qp = new QueryParser("field", new StandardAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
// make sure OR is the default:
assertEquals(QueryParser.OR_OPERATOR, qp.getDefaultOperator());
qp.setDefaultOperator(QueryParser.AND_OPERATOR);
@@ -321,7 +325,7 @@
assertQueryEquals("term 1.0 1 2", null, "term");
assertQueryEquals("term term1 term2", null, "term term term");
- Analyzer a = new StandardAnalyzer();
+ Analyzer a = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
assertQueryEquals("3", a, "3");
assertQueryEquals("term 1.0 1 2", a, "term 1.0 1 2");
assertQueryEquals("term term1 term2", a, "term term1 term2");
@@ -446,7 +450,7 @@
assertQueryEquals("[ a TO z]", null, "[a TO z]");
assertEquals(MultiTermQuery.CONSTANT_SCORE_AUTO_REWRITE_DEFAULT, ((TermRangeQuery)getQuery("[ a TO z]", null)).getRewriteMethod());
- QueryParser qp = new QueryParser("field", new SimpleAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new SimpleAnalyzer());
qp.setMultiTermRewriteMethod(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE);
assertEquals(MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE,((TermRangeQuery)qp.parse("[ a TO z]")).getRewriteMethod());
@@ -472,7 +476,7 @@
iw.close();
IndexSearcher is = new IndexSearcher(ramDir, true);
- QueryParser qp = new QueryParser("content", new WhitespaceAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "content", new WhitespaceAnalyzer());
// 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
@@ -569,7 +573,7 @@
final String defaultField = "default";
final String monthField = "month";
final String hourField = "hour";
- QueryParser qp = new QueryParser("field", new SimpleAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new SimpleAnalyzer());
// Don't set any date resolution and verify if DateField is used
assertDateRangeQueryEquals(qp, defaultField, startDate, endDate,
@@ -791,8 +795,8 @@
throws Exception {
Set stopWords = new HashSet(1);
stopWords.add("on");
- StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(stopWords);
- QueryParser qp = new QueryParser("field", oneStopAnalyzer);
+ StandardAnalyzer oneStopAnalyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, stopWords);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", oneStopAnalyzer);
Query q = qp.parse("on^1.0");
assertNotNull(q);
q = qp.parse("\"hello\"^2.0");
@@ -804,7 +808,7 @@
q = qp.parse("\"on\"^1.0");
assertNotNull(q);
- QueryParser qp2 = new QueryParser("field", new StandardAnalyzer());
+ QueryParser qp2 = new QueryParser(Version.LUCENE_CURRENT, "field", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
q = qp2.parse("the^3");
// "the" is a stop word so the result is an empty query:
assertNotNull(q);
@@ -852,7 +856,7 @@
public void testBooleanQuery() throws Exception {
BooleanQuery.setMaxClauseCount(2);
try {
- QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new WhitespaceAnalyzer());
qp.parse("one two three");
fail("ParseException expected due to too many boolean clauses");
} catch (ParseException expected) {
@@ -864,7 +868,7 @@
* This test differs from TestPrecedenceQueryParser
*/
public void testPrecedence() throws Exception {
- QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new WhitespaceAnalyzer());
Query query1 = qp.parse("A AND B OR C AND D");
Query query2 = qp.parse("+A +B +C +D");
assertEquals(query1, query2);
@@ -888,7 +892,7 @@
public void testStarParsing() throws Exception {
final int[] type = new int[1];
- QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer()) {
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new WhitespaceAnalyzer()) {
protected Query getWildcardQuery(String field, String termStr) throws ParseException {
// override error checking of superclass
type[0]=1;
@@ -944,7 +948,7 @@
}
public void testStopwords() throws Exception {
- QueryParser qp = new QueryParser("a", new StopAnalyzer(new String[]{"the", "foo"}));
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT, StopFilter.makeStopSet(new String[]{"the", "foo"})));
Query result = qp.parse("a:the OR a:foo");
assertNotNull("result is null and it shouldn't be", result);
assertTrue("result is not a BooleanQuery", result instanceof BooleanQuery);
@@ -960,30 +964,24 @@
}
public void testPositionIncrement() throws Exception {
- boolean dflt = StopFilter.getEnablePositionIncrementsDefault();
- StopFilter.setEnablePositionIncrementsDefault(true);
- try {
- QueryParser qp = new QueryParser("a", new StopAnalyzer(new String[]{"the", "in", "are", "this"}));
- qp.setEnablePositionIncrements(true);
- String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
- // 0 2 5 7 8
- int expectedPositions[] = {1,3,4,6,9};
- PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
- //System.out.println("Query text: "+qtxt);
- //System.out.println("Result: "+pq);
- Term t[] = pq.getTerms();
- int pos[] = pq.getPositions();
- for (int i = 0; i < t.length; i++) {
- //System.out.println(i+". "+t[i]+" pos: "+pos[i]);
- assertEquals("term "+i+" = "+t[i]+" has wrong term-position!",expectedPositions[i],pos[i]);
- }
- } finally {
- StopFilter.setEnablePositionIncrementsDefault(dflt);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT, StopFilter.makeStopSet(new String[]{"the", "in", "are", "this"})));
+ qp.setEnablePositionIncrements(true);
+ String qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
+ // 0 2 5 7 8
+ int expectedPositions[] = {1,3,4,6,9};
+ PhraseQuery pq = (PhraseQuery) qp.parse(qtxt);
+ //System.out.println("Query text: "+qtxt);
+ //System.out.println("Result: "+pq);
+ Term t[] = pq.getTerms();
+ int pos[] = pq.getPositions();
+ for (int i = 0; i < t.length; i++) {
+ //System.out.println(i+". "+t[i]+" pos: "+pos[i]);
+ assertEquals("term "+i+" = "+t[i]+" has wrong term-position!",expectedPositions[i],pos[i]);
}
}
public void testMatchAllDocs() throws Exception {
- QueryParser qp = new QueryParser("field", new WhitespaceAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", new WhitespaceAnalyzer());
assertEquals(new MatchAllDocsQuery(), qp.parse("*:*"));
assertEquals(new MatchAllDocsQuery(), qp.parse("(*:*)"));
BooleanQuery bq = (BooleanQuery)qp.parse("+*:* -*:*");
@@ -992,7 +990,7 @@
}
private void assertHits(int expected, String query, IndexSearcher is) throws ParseException, IOException {
- QueryParser qp = new QueryParser("date", new WhitespaceAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "date", new WhitespaceAnalyzer());
qp.setLocale(Locale.ENGLISH);
Query q = qp.parse(query);
ScoreDoc[] hits = is.search(q, null, 1000).scoreDocs;
@@ -1014,4 +1012,49 @@
BooleanQuery.setMaxClauseCount(originalMaxClauses);
}
+ // LUCENE-2002: make sure defaults for StandardAnalyzer's
+ // enableStopPositionIncr & QueryParser's enablePosIncr
+ // "match"
+ public void testPositionIncrements() throws Exception {
+ Directory dir = new MockRAMDirectory();
+ Analyzer a = new StandardAnalyzer(Version.LUCENE_CURRENT);
+ IndexWriter w = new IndexWriter(dir, a, IndexWriter.MaxFieldLength.UNLIMITED);
+ Document doc = new Document();
+ doc.add(new Field("f", "the wizard of ozzy", Field.Store.NO, Field.Index.ANALYZED));
+ w.addDocument(doc);
+ IndexReader r = w.getReader();
+ w.close();
+ IndexSearcher s = new IndexSearcher(r);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "f", a);
+ Query q = qp.parse("\"wizard of ozzy\"");
+ assertEquals(1, s.search(q, 1).totalHits);
+ r.close();
+ dir.close();
+ }
+
+ // LUCENE-2002: when we run javacc to regen QueryParser,
+ // we also run a replaceregexp step to fix 2 of the public
+ // ctors (change them to protected):
+ //
+ // protected QueryParser(CharStream stream)
+ //
+ // protected QueryParser(QueryParserTokenManager tm)
+ //
+ // This test is here as a safety, in case that ant step
+ // doesn't work for some reason.
+ public void testProtectedCtors() throws Exception {
+ try {
+ QueryParser.class.getConstructor(new Class[] {CharStream.class});
+ fail("please switch public QueryParser(CharStream) to be protected");
+ } catch (NoSuchMethodException nsme) {
+ // expected
+ }
+ try {
+ QueryParser.class.getConstructor(new Class[] {QueryParserTokenManager.class});
+ fail("please switch public QueryParser(QueryParserTokenManager) to be protected");
+ } catch (NoSuchMethodException nsme) {
+ // expected
+ }
+ }
+
}
Propchange: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Oct 29 01:00:08 2009
@@ -1,3 +1,3 @@
/lucene/java/branches/lucene_2_4/src/test/org/apache/lucene/queryParser/TestQueryParser.java:748824
-/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java:824919-825624
+/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/queryParser/TestQueryParser.java:824919-830375
/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestQueryParser.java:821379,821431
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBoolean2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBoolean2.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBoolean2.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBoolean2.java Thu Oct 29 01:00:08 2009
@@ -29,6 +29,7 @@
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Version;
/** Test BooleanQuery2 against BooleanQuery by overriding the standard query parser.
* This also tests the scoring order of BooleanQuery.
@@ -59,7 +60,7 @@
};
public Query makeQuery(String queryText) throws ParseException {
- Query q = (new QueryParser(field, new WhitespaceAnalyzer())).parse(queryText);
+ Query q = (new QueryParser(Version.LUCENE_CURRENT, field, new WhitespaceAnalyzer())).parse(queryText);
return q;
}
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBooleanOr.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBooleanOr.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBooleanOr.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestBooleanOr.java Thu Oct 29 01:00:08 2009
@@ -135,7 +135,7 @@
RAMDirectory rd = new RAMDirectory();
//
- IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(rd, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
//
Document d = new Document();
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java Thu Oct 29 01:00:08 2009
@@ -32,7 +32,7 @@
public class TestCachingWrapperFilter extends LuceneTestCase {
public void testCachingWorks() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.close();
IndexReader reader = IndexReader.open(dir, true);
@@ -71,7 +71,7 @@
public void testIsCacheAble() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writer.close();
IndexReader reader = IndexReader.open(dir, true);
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Thu Oct 29 01:00:08 2009
@@ -70,7 +70,7 @@
private Directory getIndex()
throws IOException {
RAMDirectory indexStore = new RAMDirectory ();
- IndexWriter writer = new IndexWriter (indexStore, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter (indexStore, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
RandomGen random = new RandomGen(newRandom());
for (int i=0; i<INDEX_SIZE; ++i) { // don't decrease; if to low the problem doesn't show up
Document doc = new Document();
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java Thu Oct 29 01:00:08 2009
@@ -33,6 +33,7 @@
import org.apache.lucene.search.SortField;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
/**
* Test date sorting, i.e. auto-sorting of fields with type "long".
@@ -74,7 +75,7 @@
Sort sort = new Sort(new SortField(DATE_TIME_FIELD, SortField.STRING, true));
- QueryParser queryParser = new QueryParser(TEXT_FIELD, new WhitespaceAnalyzer());
+ QueryParser queryParser = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD, new WhitespaceAnalyzer());
Query query = queryParser.parse("Document");
// Execute the search and process the search results.
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestExplanations.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestExplanations.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestExplanations.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestExplanations.java Thu Oct 29 01:00:08 2009
@@ -32,6 +32,7 @@
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Version;
/**
* Tests primitive queries (ie: that rewrite to themselves) to
@@ -51,7 +52,7 @@
public static final String KEY = "KEY";
public static final String FIELD = "field";
public static final QueryParser qp =
- new QueryParser(FIELD, new WhitespaceAnalyzer());
+ new QueryParser(Version.LUCENE_CURRENT, FIELD, new WhitespaceAnalyzer());
public void tearDown() throws Exception {
super.tearDown();
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFuzzyQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFuzzyQuery.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFuzzyQuery.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFuzzyQuery.java Thu Oct 29 01:00:08 2009
@@ -26,6 +26,7 @@
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.Term;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
/**
* Tests {@link FuzzyQuery}.
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java Thu Oct 29 01:00:08 2009
@@ -100,7 +100,7 @@
assertEquals(2, hits.length);
// test parsable toString()
- QueryParser qp = new QueryParser("key", analyzer);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "key", analyzer);
hits = is.search(qp.parse(new MatchAllDocsQuery().toString()), null, 1000).scoreDocs;
assertEquals(2, hits.length);
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiPhraseQuery.java Thu Oct 29 01:00:08 2009
@@ -33,6 +33,7 @@
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
+import java.util.Collections;
/**
* This class tests the MultiPhraseQuery class.
@@ -170,7 +171,7 @@
public void testPhrasePrefixWithBooleanQuery() throws IOException {
RAMDirectory indexStore = new RAMDirectory();
- IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(new HashSet(0)), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.emptySet()), true, IndexWriter.MaxFieldLength.LIMITED);
add("This is a test", "object", writer);
add("a note", "note", writer);
writer.close();
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcher.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcher.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcher.java Thu Oct 29 01:00:08 2009
@@ -30,6 +30,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.util.Version;
import java.io.IOException;
import java.util.Collections;
@@ -84,9 +85,9 @@
lDoc3.add(new Field("handle", "1", Field.Store.YES, Field.Index.NOT_ANALYZED));
// creating an index writer for the first index
- IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
// creating an index writer for the second index, but writing nothing
- IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
//--------------------------------------------------------------------
// scenario 1
@@ -103,7 +104,7 @@
writerB.close();
// creating the query
- QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
+ QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "fulltext", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query query = parser.parse("handle:1");
// building the searchables
@@ -130,7 +131,7 @@
//--------------------------------------------------------------------
// adding one document to the empty index
- writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writerB.addDocument(lDoc);
writerB.optimize();
writerB.close();
@@ -176,7 +177,7 @@
readerB.close();
// optimizing the index with the writer
- writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
writerB.optimize();
writerB.close();
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java Thu Oct 29 01:00:08 2009
@@ -26,6 +26,7 @@
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
import java.io.IOException;
@@ -88,7 +89,7 @@
private void checkQuery(String queryStr) throws IOException, ParseException {
// check result hit ranking
if(verbose) System.out.println("Query: " + queryStr);
- QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+ QueryParser queryParser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query query = queryParser.parse(queryStr);
ScoreDoc[] multiSearcherHits = multiSearcher.search(query, null, 1000).scoreDocs;
ScoreDoc[] singleSearcherHits = singleSearcher.search(query, null, 1000).scoreDocs;
@@ -114,12 +115,12 @@
super.setUp();
// create MultiSearcher from two seperate searchers
Directory d1 = new RAMDirectory();
- IndexWriter iw1 = new IndexWriter(d1, new StandardAnalyzer(), true,
+ IndexWriter iw1 = new IndexWriter(d1, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
addCollection1(iw1);
iw1.close();
Directory d2 = new RAMDirectory();
- IndexWriter iw2 = new IndexWriter(d2, new StandardAnalyzer(), true,
+ IndexWriter iw2 = new IndexWriter(d2, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
addCollection2(iw2);
iw2.close();
@@ -131,7 +132,7 @@
// create IndexSearcher which contains all documents
Directory d = new RAMDirectory();
- IndexWriter iw = new IndexWriter(d, new StandardAnalyzer(), true,
+ IndexWriter iw = new IndexWriter(d, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
addCollection1(iw);
addCollection2(iw);
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestNot.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestNot.java Thu Oct 29 01:00:08 2009
@@ -25,6 +25,7 @@
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.util.Version;
/** Similarity unit test.
*
@@ -48,7 +49,7 @@
writer.close();
Searcher searcher = new IndexSearcher(store, true);
- QueryParser parser = new QueryParser("field", new SimpleAnalyzer());
+ QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "field", new SimpleAnalyzer());
Query query = parser.parse("a NOT b");
//System.out.println(query);
ScoreDoc[] hits = searcher.search(query, null, 1000).scoreDocs;
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPhraseQuery.java Thu Oct 29 01:00:08 2009
@@ -25,6 +25,7 @@
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
import java.io.IOException;
import java.io.Reader;
@@ -201,7 +202,7 @@
public void testPhraseQueryWithStopAnalyzer() throws Exception {
RAMDirectory directory = new RAMDirectory();
- StopAnalyzer stopAnalyzer = new StopAnalyzer();
+ StopAnalyzer stopAnalyzer = new StopAnalyzer(Version.LUCENE_24);
IndexWriter writer = new IndexWriter(directory, stopAnalyzer, true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
@@ -220,7 +221,7 @@
QueryUtils.check(query,searcher);
- // currently StopAnalyzer does not leave "holes", so this matches.
+ // StopAnalyzer as of 2.4 does not leave "holes", so this matches.
query = new PhraseQuery();
query.add(new Term("field", "words"));
query.add(new Term("field", "here"));
@@ -357,9 +358,8 @@
}
public void testToString() throws Exception {
- StopAnalyzer analyzer = new StopAnalyzer();
- StopFilter.setEnablePositionIncrementsDefault(true);
- QueryParser qp = new QueryParser("field", analyzer);
+ StopAnalyzer analyzer = new StopAnalyzer(Version.LUCENE_CURRENT);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field", analyzer);
qp.setEnablePositionIncrements(true);
PhraseQuery q = (PhraseQuery)qp.parse("\"this hi this is a test is\"");
assertEquals("field:\"? hi ? ? ? test\"", q.toString());
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestPositionIncrement.java Thu Oct 29 01:00:08 2009
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import org.apache.lucene.analysis.Analyzer;
@@ -31,6 +32,7 @@
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import org.apache.lucene.analysis.tokenattributes.PayloadAttribute;
import org.apache.lucene.analysis.tokenattributes.TermAttribute;
+import org.apache.lucene.analysis.CharArraySet;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriter;
@@ -49,6 +51,7 @@
import org.apache.lucene.search.spans.SpanQuery;
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.search.spans.Spans;
+import org.apache.lucene.util.Version;
/**
* Term position unit test.
@@ -186,7 +189,7 @@
assertEquals(0, hits.length);
// should not find "1 2" because there is a gap of 1 in the index
- QueryParser qp = new QueryParser("field",
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "field",
new StopWhitespaceAnalyzer(false));
q = (PhraseQuery) qp.parse("\"1 2\"");
hits = searcher.search(q, null, 1000).scoreDocs;
@@ -210,7 +213,7 @@
assertEquals(0, hits.length);
// when both qp qnd stopFilter propagate increments, we should find the doc.
- qp = new QueryParser("field",
+ qp = new QueryParser(Version.LUCENE_CURRENT, "field",
new StopWhitespaceAnalyzer(true));
qp.setEnablePositionIncrements(true);
q = (PhraseQuery) qp.parse("\"1 stop 2\"");
@@ -226,7 +229,7 @@
}
public TokenStream tokenStream(String fieldName, Reader reader) {
TokenStream ts = a.tokenStream(fieldName,reader);
- return new StopFilter(enablePositionIncrements, ts, new String[]{"stop"});
+ return new StopFilter(enablePositionIncrements, ts, new CharArraySet(Collections.singleton("stop"), true));
}
}
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestQueryWrapperFilter.java Thu Oct 29 01:00:08 2009
@@ -33,7 +33,7 @@
public void testBasic() throws Exception {
Directory dir = new RAMDirectory();
- IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(), true,
+ IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true,
IndexWriter.MaxFieldLength.LIMITED);
Document doc = new Document();
doc.add(new Field("field", "value", Store.NO, Index.ANALYZED));
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimilarity.java Thu Oct 29 01:00:08 2009
@@ -29,6 +29,7 @@
import org.apache.lucene.analysis.SimpleAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
+import org.apache.lucene.search.Explanation.IDFExplanation;
/** Similarity unit test.
*
@@ -45,9 +46,18 @@
public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
public float tf(float freq) { return freq; }
public float sloppyFreq(int distance) { return 2.0f; }
- public float idf(Collection terms, Searcher searcher) { return 1.0f; }
public float idf(int docFreq, int numDocs) { return 1.0f; }
public float coord(int overlap, int maxOverlap) { return 1.0f; }
+ public IDFExplanation idfExplain(Collection terms, Searcher searcher) throws IOException {
+ return new IDFExplanation() {
+ public float getIdf() {
+ return 1.0f;
+ }
+ public String explain() {
+ return "Inexplicable";
+ }
+ };
+ }
}
public void testSimilarity() throws Exception {
@@ -80,7 +90,7 @@
this.scorer = scorer;
}
public final void collect(int doc) throws IOException {
- assertTrue(scorer.score() == 1.0f);
+ assertEquals(new Float(1.0f), new Float(scorer.score()));
}
public void setNextReader(IndexReader reader, int docBase) {}
public boolean acceptsDocsOutOfOrder() {
@@ -100,7 +110,7 @@
}
public final void collect(int doc) throws IOException {
//System.out.println("Doc=" + doc + " score=" + score);
- assertTrue(scorer.score() == (float)doc+base+1);
+ assertEquals(new Float((float)doc+base+1), new Float(scorer.score()));
}
public void setNextReader(IndexReader reader, int docBase) {
base = docBase;
@@ -114,8 +124,7 @@
pq.add(a);
pq.add(c);
//System.out.println(pq.toString("field"));
- searcher.search
- (pq,
+ searcher.search(pq,
new Collector() {
private Scorer scorer;
public void setScorer(Scorer scorer) throws IOException {
@@ -123,7 +132,7 @@
}
public final void collect(int doc) throws IOException {
//System.out.println("Doc=" + doc + " score=" + score);
- assertTrue(scorer.score() == 1.0f);
+ assertEquals(new Float(1.0f), new Float(scorer.score()));
}
public void setNextReader(IndexReader reader, int docBase) {}
public boolean acceptsDocsOutOfOrder() {
@@ -140,7 +149,7 @@
}
public final void collect(int doc) throws IOException {
//System.out.println("Doc=" + doc + " score=" + score);
- assertTrue(scorer.score() == 2.0f);
+ assertEquals(new Float(2.0f), new Float(scorer.score()));
}
public void setNextReader(IndexReader reader, int docBase) {}
public boolean acceptsDocsOutOfOrder() {
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimpleExplanations.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimpleExplanations.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimpleExplanations.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSimpleExplanations.java Thu Oct 29 01:00:08 2009
@@ -28,6 +28,7 @@
import org.apache.lucene.search.spans.SpanTermQuery;
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.MockRAMDirectory;
+import org.apache.lucene.util.Version;
/**
@@ -316,8 +317,8 @@
Document lDoc3 = new Document();
lDoc3.add(new Field("handle", "1 2", Field.Store.YES, Field.Index.ANALYZED));
- IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
- IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerA = new IndexWriter(indexStoreA, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
+ IndexWriter writerB = new IndexWriter(indexStoreB, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
writerA.addDocument(lDoc);
writerA.addDocument(lDoc2);
@@ -327,7 +328,7 @@
writerB.addDocument(lDoc3);
writerB.close();
- QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
+ QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, "fulltext", new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT));
Query query = parser.parse("handle:1");
Searcher[] searchers = new Searcher[2];
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTermVectors.java Thu Oct 29 01:00:08 2009
@@ -258,7 +258,7 @@
//System.out.println("Doc Id: " + docId + " freq " + freq);
TermFreqVector vector = knownSearcher.reader.getTermFreqVector(docId, "field");
float tf = sim.tf(freq);
- float idf = sim.idf(term, knownSearcher);
+ float idf = sim.idf(knownSearcher.docFreq(term), knownSearcher.maxDoc());
//float qNorm = sim.queryNorm()
//This is fine since we don't have stop words
float lNorm = sim.lengthNorm("field", vector.getTerms().length);
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestTimeLimitingCollector.java Thu Oct 29 01:00:08 2009
@@ -31,6 +31,7 @@
import org.apache.lucene.store.Directory;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Version;
/**
* Tests the {@link TimeLimitingCollector}. This test checks (1) search
@@ -85,7 +86,7 @@
for (int i = 0; i < docText.length; i++) {
qtxt += ' ' + docText[i]; // large query so that search will be longer
}
- QueryParser queryParser = new QueryParser(FIELD_NAME, new WhitespaceAnalyzer());
+ QueryParser queryParser = new QueryParser(Version.LUCENE_CURRENT, FIELD_NAME, new WhitespaceAnalyzer());
query = queryParser.parse(qtxt);
// warm the searcher
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestWildcard.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestWildcard.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestWildcard.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestWildcard.java Thu Oct 29 01:00:08 2009
@@ -28,6 +28,7 @@
import org.apache.lucene.index.Term;
import org.apache.lucene.queryParser.QueryParser;
import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.Version;
import java.io.IOException;
@@ -167,7 +168,7 @@
public void testParsingAndSearching() throws Exception {
String field = "content";
boolean dbg = false;
- QueryParser qp = new QueryParser(field, new WhitespaceAnalyzer());
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, field, new WhitespaceAnalyzer());
qp.setAllowLeadingWildcard(true);
String docs[] = {
"\\ abcdefg1",
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/FunctionTestSetup.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/FunctionTestSetup.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/FunctionTestSetup.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/FunctionTestSetup.java Thu Oct 29 01:00:08 2009
@@ -86,7 +86,7 @@
// prepare a small index with just a few documents.
super.setUp();
dir = new RAMDirectory();
- anlzr = new StandardAnalyzer();
+ anlzr = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT);
IndexWriter iw = new IndexWriter(dir, anlzr,
IndexWriter.MaxFieldLength.LIMITED);
// add docs not exactly in natural ID order, to verify we do check the order of docs by scores
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/function/TestCustomScoreQuery.java Thu Oct 29 01:00:08 2009
@@ -28,6 +28,7 @@
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryUtils;
import org.apache.lucene.search.TopDocs;
+import org.apache.lucene.util.Version;
/**
* Test CustomScoreQuery search.
@@ -139,7 +140,7 @@
float boost = (float) dboost;
IndexSearcher s = new IndexSearcher(dir, true);
FieldScoreQuery qValSrc = new FieldScoreQuery(field,tp); // a query that would score by the field
- QueryParser qp = new QueryParser(TEXT_FIELD,anlzr);
+ QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, TEXT_FIELD,anlzr);
String qtxt = "first aid text"; // from the doc texts in FunctionQuerySetup.
// regular (boolean) query.
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/payloads/TestPayloadNearQuery.java Thu Oct 29 01:00:08 2009
@@ -40,6 +40,7 @@
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.English;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.search.Explanation.IDFExplanation;
public class TestPayloadNearQuery extends LuceneTestCase {
@@ -214,8 +215,17 @@
return 1;
}
// idf used for phrase queries
- public float idf(Collection terms, Searcher searcher) {
- return 1;
- }
+ // idf used for phrase queries
+ public IDFExplanation idfExplain(Collection terms, Searcher searcher) throws IOException {
+ return new IDFExplanation() {
+ public float getIdf() {
+ return 1.0f;
+ }
+
+ public String explain() {
+ return "Inexplicable";
+ }
+ };
+ }
}
}
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestNearSpansOrdered.java Thu Oct 29 01:00:08 2009
@@ -30,13 +30,14 @@
import org.apache.lucene.search.Scorer;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.Version;
public class TestNearSpansOrdered extends LuceneTestCase {
protected IndexSearcher searcher;
public static final String FIELD = "field";
public static final QueryParser qp =
- new QueryParser(FIELD, new WhitespaceAnalyzer());
+ new QueryParser(Version.LUCENE_CURRENT, FIELD, new WhitespaceAnalyzer());
public void tearDown() throws Exception {
super.tearDown();
@@ -168,9 +169,7 @@
*/
public void testSpanNearScorerExplain() throws Exception {
SpanNearQuery q = makeQuery();
- Weight w = q.weight(searcher);
- Scorer s = w.scorer(searcher.getIndexReader(), true, false);
- Explanation e = s.explain(1);
+ Explanation e = q.weight(searcher).explain(searcher.getIndexReader(), 1);
assertTrue("Scorer explanation value for doc#1 isn't positive: "
+ e.toString(),
0.0f < e.getValue());
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpans.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpans.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpans.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpans.java Thu Oct 29 01:00:08 2009
@@ -39,7 +39,7 @@
import org.apache.lucene.util.LuceneTestCase;
import java.io.IOException;
-import java.util.HashSet;
+import java.util.Collections;
public class TestSpans extends LuceneTestCase {
private IndexSearcher searcher;
@@ -449,7 +449,7 @@
// LUCENE-1404
public void testNPESpanQuery() throws Throwable {
final Directory dir = new MockRAMDirectory();
- final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(new HashSet(0)), IndexWriter.MaxFieldLength.LIMITED);
+ final IndexWriter writer = new IndexWriter(dir, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.emptySet()), IndexWriter.MaxFieldLength.LIMITED);
// Add documents
addDoc(writer, "1", "the big dogs went running to the market");
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced.java Thu Oct 29 01:00:08 2009
@@ -55,7 +55,7 @@
// create test index
mDirectory = new RAMDirectory();
- final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+ final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
addDocument(writer, "1", "I think it should work.");
addDocument(writer, "2", "I think it should work.");
addDocument(writer, "3", "I think it should work.");
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/search/spans/TestSpansAdvanced2.java Thu Oct 29 01:00:08 2009
@@ -39,7 +39,7 @@
super.setUp();
// create test index
- final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED);
+ final IndexWriter writer = new IndexWriter(mDirectory, new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT), false, IndexWriter.MaxFieldLength.LIMITED);
addDocument(writer, "A", "Should we, could we, would we?");
addDocument(writer, "B", "It should. Should it?");
addDocument(writer, "C", "It shouldn't.");
Modified: lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestWindowsMMap.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestWindowsMMap.java?rev=830815&r1=830814&r2=830815&view=diff
==============================================================================
--- lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestWindowsMMap.java (original)
+++ lucene/java/branches/flex_1458_2_9_back_compat_tests/src/test/org/apache/lucene/store/TestWindowsMMap.java Thu Oct 29 01:00:08 2009
@@ -17,7 +17,7 @@
* limitations under the License.
*/
-import java.util.HashSet;
+import java.util.Collections;
import java.util.Random;
import java.io.File;
@@ -68,7 +68,7 @@
// plan to add a set of useful stopwords, consider changing some of the
// interior filters.
- StandardAnalyzer analyzer = new StandardAnalyzer(new HashSet());
+ StandardAnalyzer analyzer = new StandardAnalyzer(org.apache.lucene.util.Version.LUCENE_CURRENT, Collections.emptySet());
// TODO: something about lock timeouts and leftover locks.
IndexWriter writer = new IndexWriter(storeDirectory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED);
IndexSearcher searcher = new IndexSearcher(storeDirectory, true);