Return-Path: Delivered-To: apmail-lucene-java-commits-archive@www.apache.org Received: (qmail 78140 invoked from network); 29 Oct 2009 01:00:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Oct 2009 01:00:47 -0000 Received: (qmail 24994 invoked by uid 500); 29 Oct 2009 01:00:47 -0000 Delivered-To: apmail-lucene-java-commits-archive@lucene.apache.org Received: (qmail 24914 invoked by uid 500); 29 Oct 2009 01:00:47 -0000 Mailing-List: contact java-commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-commits@lucene.apache.org Received: (qmail 24905 invoked by uid 99); 29 Oct 2009 01:00:47 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2009 01:00:47 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2009 01:00:34 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id D127C23889B8; Thu, 29 Oct 2009 01:00:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: 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... Date: Thu, 29 Oct 2009 01:00:10 -0000 To: java-commits@lucene.apache.org From: markrmiller@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091029010011.D127C23889B8@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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