lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r387550 [4/4] - in /lucene/java/trunk: ./ contrib/analyzers/src/java/org/apache/lucene/analysis/br/ contrib/analyzers/src/java/org/apache/lucene/analysis/cz/ contrib/analyzers/src/java/org/apache/lucene/analysis/de/ contrib/analyzers/src/ja...
Date Tue, 21 Mar 2006 15:36:42 GMT
Modified: lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/English.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/English.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/English.java (original)
+++ lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/English.java Tue Mar 21 07:36:32 2006
@@ -1,102 +0,0 @@
-package org.apache.lucene.util;
-
-/**
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-public class English {
-
-  public static String intToEnglish(int i) {
-    StringBuffer result = new StringBuffer();
-    intToEnglish(i, result);
-    return result.toString();
-  }
-
-  public static void intToEnglish(int i, StringBuffer result) {
-    if (i == 0) {
-      result.append("zero");
-      return;
-    }
-    if (i < 0) {
-      result.append("minus ");
-      i = -i;
-    }
-    if (i >= 1000000000) {			  // billions
-      intToEnglish(i/1000000000, result);
-      result.append("billion, ");
-      i = i%1000000000;
-    }
-    if (i >= 1000000) {				  // millions
-      intToEnglish(i/1000000, result);
-      result.append("million, ");
-      i = i%1000000;
-    }
-    if (i >= 1000) {				  // thousands
-      intToEnglish(i/1000, result);
-      result.append("thousand, ");
-      i = i%1000;
-    }
-    if (i >= 100) {				  // hundreds
-      intToEnglish(i/100, result);
-      result.append("hundred ");
-      i = i%100;
-    }
-    if (i >= 20) {
-      switch (i/10) {
-      case 9 : result.append("ninety"); break;
-      case 8 : result.append("eighty"); break;
-      case 7 : result.append("seventy"); break;
-      case 6 : result.append("sixty"); break;
-      case 5 : result.append("fifty"); break;
-      case 4 : result.append("forty"); break;
-      case 3 : result.append("thirty"); break;
-      case 2 : result.append("twenty"); break;
-      }
-      i = i%10;
-      if (i == 0)
-        result.append(" ");
-      else 
-        result.append("-");
-    }
-    switch (i) {
-    case 19 : result.append("nineteen "); break;
-    case 18 : result.append("eighteen "); break;
-    case 17 : result.append("seventeen "); break;
-    case 16 : result.append("sixteen "); break;
-    case 15 : result.append("fifteen "); break;
-    case 14 : result.append("fourteen "); break;
-    case 13 : result.append("thirteen "); break;
-    case 12 : result.append("twelve "); break;
-    case 11 : result.append("eleven "); break;
-    case 10 : result.append("ten "); break;
-    case 9 : result.append("nine "); break;
-    case 8 : result.append("eight "); break;
-    case 7 : result.append("seven "); break;
-    case 6 : result.append("six "); break;
-    case 5 : result.append("five "); break;
-    case 4 : result.append("four "); break;
-    case 3 : result.append("three "); break;
-    case 2 : result.append("two "); break;
-    case 1 : result.append("one "); break;
-    case 0 : result.append(""); break;
-    }
-  }
-
-  public static void main(String[] args) {
-    System.out.println(intToEnglish(Integer.parseInt(args[0])));
-  }
-
-}

Modified: lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/StringHelperTest.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/StringHelperTest.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/StringHelperTest.java (original)
+++ lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/StringHelperTest.java Tue Mar 21 07:36:32 2006
@@ -1,50 +0,0 @@
-package org.apache.lucene.util;
-
-/**
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import junit.framework.TestCase;
-
-public class StringHelperTest extends TestCase {
-
-
-  public StringHelperTest(String s) {
-    super(s);
-  }
-
-  protected void setUp() {
-  }
-
-  protected void tearDown() {
-
-  }
-
-  public void testStringDifference() {
-    String test1 = "test";
-    String test2 = "testing";
-    
-    int result = StringHelper.stringDifference(test1, test2);
-    assertTrue(result == 4);
-    
-    test2 = "foo";
-    result = StringHelper.stringDifference(test1, test2);
-    assertTrue(result == 0);
-    
-    test2 = "test";
-    result = StringHelper.stringDifference(test1, test2);
-    assertTrue(result == 4);
-  }
-}

Modified: lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/TestPriorityQueue.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/TestPriorityQueue.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/TestPriorityQueue.java (original)
+++ lucene/java/trunk/src/test-deprecated/org/apache/lucene/util/TestPriorityQueue.java Tue Mar 21 07:36:32 2006
@@ -1,112 +0,0 @@
-package org.apache.lucene.util;
-
-/**
- * Copyright 2004 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.util.Date;
-import java.util.Random;
-import junit.framework.TestCase;
-
-public class TestPriorityQueue
-    extends TestCase
-{
-    public TestPriorityQueue(String name)
-    {
-	super(name);
-    }
-
-    private static class IntegerQueue
-	extends PriorityQueue
-    {
-	public IntegerQueue(int count)
-	{
-	    super();
-	    initialize(count);
-	}
-
-	protected boolean lessThan(Object a, Object b)
-	{
-	    return ((Integer) a).intValue() < ((Integer) b).intValue();
-	}
-    }
-
-    public void testPQ()
-	throws Exception
-    {
-	testPQ(10000);
-    }
-
-    public static void testPQ(int count)
-    {
-	PriorityQueue pq = new IntegerQueue(count);
-	Random gen = new Random();
-	int sum = 0, sum2 = 0;
-
-	Date start = new Date();
-
-	for (int i = 0; i < count; i++)
-	{
-	    int next = gen.nextInt();
-	    sum += next;
-	    pq.put(new Integer(next));
-	}
-
-	//      Date end = new Date();
-
-	//      System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000);
-	//      System.out.println(" microseconds/put");
-
-	//      start = new Date();
-
-	int last = Integer.MIN_VALUE;
-	for (int i = 0; i < count; i++)
-	{
-	    Integer next = (Integer)pq.pop();
-	    assertTrue(next.intValue() >= last);
-	    last = next.intValue();
-	    sum2 += last;
-	}
-
-	assertEquals(sum, sum2);
-	//      end = new Date();
-
-	//      System.out.print(((float)(end.getTime()-start.getTime()) / count) * 1000);
-	//      System.out.println(" microseconds/pop");
-    }
-
-    public void testClear()
-    {
-	PriorityQueue pq = new IntegerQueue(3);
-	pq.put(new Integer(2));
-	pq.put(new Integer(3));
-	pq.put(new Integer(1));
-	assertEquals(3, pq.size());
-	pq.clear();
-	assertEquals(0, pq.size());
-    }
-    
-    public void testFixedSize(){
-        PriorityQueue pq = new IntegerQueue(3);
-        pq.insert(new Integer(2));
-        pq.insert(new Integer(3));
-        pq.insert(new Integer(1));
-        pq.insert(new Integer(5));
-        pq.insert(new Integer(7));
-        pq.insert(new Integer(1));
-        assertEquals(3, pq.size());
-        assertEquals(3, ((Integer) pq.top()).intValue());
-    }
-}

Modified: lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/TestDemo.java Tue Mar 21 07:36:32 2006
@@ -16,8 +16,7 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-
+import junit.framework.TestCase;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
@@ -31,7 +30,7 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 
-import junit.framework.TestCase;
+import java.io.IOException;
 
 /**
  * A very simple demo used in the API documentation (src/java/overview.html).
@@ -62,7 +61,8 @@
     // Now search the index:
     IndexSearcher isearcher = new IndexSearcher(directory);
     // Parse a simple query that searches for "text":
-    Query query = QueryParser.parse("text", "fieldname", analyzer);
+      QueryParser parser = new QueryParser("fieldname", analyzer);
+    Query query = parser.parse("text");
     Hits hits = isearcher.search(query);
     assertEquals(1, hits.length());
     // Iterate through the results:

Modified: lucene/java/trunk/src/test/org/apache/lucene/ThreadSafetyTest.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/ThreadSafetyTest.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/ThreadSafetyTest.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/ThreadSafetyTest.java Tue Mar 21 07:36:32 2006
@@ -113,9 +113,9 @@
     private void searchFor(int n, Searcher searcher)
       throws Exception {
       System.out.println("Searching for " + n);
+        QueryParser parser = new QueryParser("contents", ANALYZER);
       Hits hits =
-        searcher.search(QueryParser.parse(English.intToEnglish(n), "contents",
-                                          ANALYZER));
+        searcher.search(parser.parse(English.intToEnglish(n)));
       System.out.println("Search for " + n + ": total=" + hits.length());
       for (int j = 0; j < Math.min(3, hits.length()); j++) {
         System.out.println("Hit for " + n + ": " + hits.doc(j).get("id"));

Modified: lucene/java/trunk/src/test/org/apache/lucene/document/TestBinaryDocument.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/document/TestBinaryDocument.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/document/TestBinaryDocument.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/document/TestBinaryDocument.java Tue Mar 21 07:36:32 2006
@@ -91,7 +91,7 @@
     assertTrue(stringFldCompressedTest.equals(binaryValCompressed));
     
     /** delete the document from index */
-    reader.delete(0);
+    reader.deleteDocument(0);
     assertEquals(0, reader.numDocs());
     
     reader.close();

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexModifier.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexModifier.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexModifier.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexModifier.java Tue Mar 21 07:36:32 2006
@@ -16,14 +16,7 @@
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.util.EmptyStackException;
-import java.util.Random;
-import java.util.Stack;
-
 import junit.framework.TestCase;
-
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
@@ -33,6 +26,12 @@
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.RAMDirectory;
 
+import java.io.File;
+import java.io.IOException;
+import java.util.EmptyStackException;
+import java.util.Random;
+import java.util.Stack;
+
 /**
  * Tests for the "IndexModifier" class, including accesses from two threads at the
  * same time.
@@ -56,7 +55,7 @@
     i.optimize();
     assertEquals(2, i.docCount());
     i.flush();
-    i.delete(0);
+    i.deleteDocument(0);
     assertEquals(1, i.docCount());
     i.flush();
     assertEquals(1, i.docCount());
@@ -64,7 +63,7 @@
     i.addDocument(getDoc());
     i.flush();
     assertEquals(3, i.docCount());
-    i.delete(allDocTerm);
+    i.deleteDocuments(allDocTerm);
     assertEquals(0, i.docCount());
     i.optimize();
     assertEquals(0, i.docCount());
@@ -88,7 +87,7 @@
     assertFalse(i.getUseCompoundFile());
 
     // test setting properties when internally the reader is opened:
-    i.delete(allDocTerm);
+    i.deleteDocuments(allDocTerm);
     i.setMaxBufferedDocs(100);
     i.setMergeFactor(25);
     i.setMaxFieldLength(250000);
@@ -241,7 +240,7 @@
             continue;
           }
           Term delTerm = new Term("id", new Integer(delId).toString());
-          int delCount = index.delete(delTerm);
+          int delCount = index.deleteDocuments(delTerm);
           if (delCount != 1) {
             throw new RuntimeException("Internal error: " + threadNumber + " deleted " + delCount + 
                 " documents, term=" + delTerm);

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexReader.java Tue Mar 21 07:36:32 2006
@@ -217,7 +217,7 @@
         // DELETE DOCUMENTS CONTAINING TERM: aaa
         int deleted = 0;
         reader = IndexReader.open(dir);
-        deleted = reader.delete(searchTerm);
+        deleted = reader.deleteDocuments(searchTerm);
         assertEquals("deleted count", 100, deleted);
         assertEquals("deleted docFreq", 100, reader.docFreq(searchTerm));
         assertTermDocsCount("deleted termDocs", reader, searchTerm, 0);
@@ -290,7 +290,7 @@
         // NOTE: the reader was created when only "aaa" documents were in
         int deleted = 0;
         try {
-            deleted = reader.delete(searchTerm);
+            deleted = reader.deleteDocuments(searchTerm);
             fail("Delete allowed on an index reader with stale segment information");
         } catch (IOException e) {
             /* success */
@@ -305,7 +305,7 @@
         assertTermDocsCount("first reader", reader, searchTerm, 100);
         assertTermDocsCount("first reader", reader, searchTerm2, 100);
 
-        deleted = reader.delete(searchTerm);
+        deleted = reader.deleteDocuments(searchTerm);
         assertEquals("deleted count", 100, deleted);
         assertEquals("deleted docFreq", 100, reader.docFreq(searchTerm));
         assertEquals("deleted docFreq", 100, reader.docFreq(searchTerm2));
@@ -384,13 +384,13 @@
       writer  = new IndexWriter(dir, new WhitespaceAnalyzer(), false);
       IndexReader reader = IndexReader.open(dir);
       try {
-        reader.delete(0);
+        reader.deleteDocument(0);
         fail("expected lock");
       } catch(IOException e) {
         // expected exception
       }
       IndexReader.unlock(dir);		// this should not be done in the real world! 
-      reader.delete(0);
+      reader.deleteDocument(0);
       reader.close();
       writer.close();
     }
@@ -402,8 +402,8 @@
       addDocumentWithFields(writer);
       writer.close();
       IndexReader reader = IndexReader.open(dir);
-      reader.delete(0);
-      reader.delete(1);
+      reader.deleteDocument(0);
+      reader.deleteDocument(1);
       reader.undeleteAll();
       reader.close();
       reader = IndexReader.open(dir);
@@ -463,7 +463,7 @@
         // delete documents containing term: aaa
         // when the reader is closed, the segment info is updated and
         // the first reader is now stale
-        reader2.delete(searchTerm1);
+        reader2.deleteDocuments(searchTerm1);
         assertEquals("after delete 1", 100, reader2.docFreq(searchTerm1));
         assertEquals("after delete 1", 100, reader2.docFreq(searchTerm2));
         assertEquals("after delete 1", 100, reader2.docFreq(searchTerm3));
@@ -484,7 +484,7 @@
         // ATTEMPT TO DELETE FROM STALE READER
         // delete documents containing term: bbb
         try {
-            reader1.delete(searchTerm2);
+            reader1.deleteDocuments(searchTerm2);
             fail("Delete allowed from a stale index reader");
         } catch (IOException e) {
             /* success */
@@ -500,7 +500,7 @@
         assertTermDocsCount("reopened", reader1, searchTerm2, 100);
         assertTermDocsCount("reopened", reader1, searchTerm3, 100);
 
-        reader1.delete(searchTerm2);
+        reader1.deleteDocuments(searchTerm2);
         assertEquals("deleted 2", 100, reader1.docFreq(searchTerm1));
         assertEquals("deleted 2", 100, reader1.docFreq(searchTerm2));
         assertEquals("deleted 2", 100, reader1.docFreq(searchTerm3));

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestIndexWriter.java Tue Mar 21 07:36:32 2006
@@ -39,7 +39,7 @@
         // delete 40 documents
         reader = IndexReader.open(dir);
         for (i = 0; i < 40; i++) {
-            reader.delete(i);
+            reader.deleteDocument(i);
         }
         reader.close();
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiReader.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiReader.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestMultiReader.java Tue Mar 21 07:36:32 2006
@@ -75,7 +75,7 @@
     MultiReader reader = new MultiReader(dir, sis, false, readers);
     assertTrue(reader != null);
     assertEquals( 2, reader.numDocs() );
-    reader.delete(0);
+    reader.deleteDocument(0);
     assertEquals( 1, reader.numDocs() );
     reader.undeleteAll();
     assertEquals( 2, reader.numDocs() );

Modified: lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/index/TestSegmentReader.java Tue Mar 21 07:36:32 2006
@@ -77,7 +77,7 @@
     SegmentReader deleteReader = SegmentReader.get(new SegmentInfo("seg-to-delete", 1, dir));
     assertTrue(deleteReader != null);
     assertTrue(deleteReader.numDocs() == 1);
-    deleteReader.delete(0);
+    deleteReader.deleteDocument(0);
     assertTrue(deleteReader.isDeleted(0) == true);
     assertTrue(deleteReader.hasDeletions() == true);
     assertTrue(deleteReader.numDocs() == 0);

Modified: lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/queryParser/TestMultiFieldQueryParser.java Tue Mar 21 07:36:32 2006
@@ -16,10 +16,7 @@
  * limitations under the License.
  */
 
-import java.io.Reader;
-
 import junit.framework.TestCase;
-
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
@@ -34,6 +31,8 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 
+import java.io.Reader;
+
 /**
  * Tests QueryParser.
  * @author Daniel Naber
@@ -96,23 +95,6 @@
 
   }
   
-  // TODO: remove this for Lucene 2.0
-  public void testOldMethods() throws ParseException {
-    // testing the old static calls that are now deprecated:
-    assertQueryEquals("b:one t:one", "one");
-    assertQueryEquals("(b:one b:two) (t:one t:two)", "one two");
-    assertQueryEquals("(b:one -b:two) (t:one -t:two)", "one -two");
-    assertQueryEquals("(b:one -(b:two b:three)) (t:one -(t:two t:three))", "one -(two three)");
-    assertQueryEquals("(+b:one +b:two) (+t:one +t:two)", "+one +two");
-  }
-  
-  // TODO: remove this for Lucene 2.0
-  private void assertQueryEquals(String expected, String query) throws ParseException {
-    String[] fields = {"b", "t"};
-    Query q = MultiFieldQueryParser.parse(query, fields, new StandardAnalyzer());
-    String s = q.toString();
-    assertEquals(expected, s);
-  }
 
   public void testStaticMethod1() throws ParseException {
     String[] fields = {"b", "t"};
@@ -161,15 +143,18 @@
 
   public void testStaticMethod2Old() throws ParseException {
     String[] fields = {"b", "t"};
-    int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
-    Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer());
+    //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());
+
+    Query q = MultiFieldQueryParser.parse("one", fields, flags, new StandardAnalyzer());//, fields, flags, new StandardAnalyzer());
     assertEquals("+b:one -t:one", q.toString());
 
     q = MultiFieldQueryParser.parse("one two", fields, flags, new StandardAnalyzer());
     assertEquals("+(b:one b:two) -(t:one t:two)", q.toString());
 
     try {
-      int[] flags2 = {MultiFieldQueryParser.REQUIRED_FIELD};
+      BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
       q = MultiFieldQueryParser.parse("blah", fields, flags2, new StandardAnalyzer());
       fail();
     } catch(IllegalArgumentException e) {
@@ -197,12 +182,12 @@
   public void testStaticMethod3Old() throws ParseException {
     String[] queries = {"one", "two"};
     String[] fields = {"b", "t"};
-    int[] flags = {MultiFieldQueryParser.REQUIRED_FIELD, MultiFieldQueryParser.PROHIBITED_FIELD};
+      BooleanClause.Occur[] flags = {BooleanClause.Occur.MUST, BooleanClause.Occur.MUST_NOT};
     Query q = MultiFieldQueryParser.parse(queries, fields, flags, new StandardAnalyzer());
     assertEquals("+b:one -t:two", q.toString());
 
     try {
-      int[] flags2 = {MultiFieldQueryParser.REQUIRED_FIELD};
+      BooleanClause.Occur[] flags2 = {BooleanClause.Occur.MUST};
       q = MultiFieldQueryParser.parse(queries, fields, flags2, new StandardAnalyzer());
       fail();
     } catch(IllegalArgumentException e) {

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Tue Mar 21 07:36:32 2006
@@ -17,22 +17,15 @@
  */
 
 
-import org.apache.lucene.store.RAMDirectory;
-import org.apache.lucene.store.Directory;
-
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
+import junit.framework.TestCase;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-
-import org.apache.lucene.queryParser.QueryParser;
-import org.apache.lucene.queryParser.ParseException;
-
-import junit.framework.TestCase;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
 
 import java.text.DecimalFormat;
 import java.util.Random;
@@ -67,10 +60,10 @@
 
         for (int i = 0; i < data.length; i++) {
             Document doc = new Document();
-            doc.add(Field.Keyword("id",String.valueOf(i)));
-            doc.add(Field.Keyword("all","all"));
+            doc.add(new Field("id", String.valueOf(i), Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("id",String.valueOf(i)));
+            doc.add(new Field("all", "all", Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("all","all"));
             if (null != data[i]) {
-                doc.add(Field.Text("data",data[i]));
+                doc.add(new Field("data", data[i], Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("data",data[i]));
             }
             writer.addDocument(doc);
         }
@@ -96,7 +89,7 @@
 
         BooleanQuery q = new BooleanQuery();
         for (int i = 1; i <=4; i++) {
-            q.add(new TermQuery(new Term("data",""+i)), false, false);
+            q.add(new TermQuery(new Term("data",""+i)), BooleanClause.Occur.SHOULD);//false, false);
         }
         q.setMinimumNumberShouldMatch(2); // match at least two of 4
         verifyNrHits(q, 2);
@@ -106,10 +99,10 @@
 
         /* one required, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all", "all" )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, false);
+        q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.SHOULD);//false, false);
 
         q.setMinimumNumberShouldMatch(2); // 2 of 3 optional 
 
@@ -120,11 +113,11 @@
 
         /* two required, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all", "all" )), true,  false);
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, false);
+        q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.SHOULD);//false, false);
 
         q.setMinimumNumberShouldMatch(2); // 2 of 3 optional 
 
@@ -135,10 +128,10 @@
 
         /* one prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
 
         q.setMinimumNumberShouldMatch(2); // 2 of 3 optional 
 
@@ -149,11 +142,11 @@
 
         /* two prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "C"  )), false, true );
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "C"  )), BooleanClause.Occur.MUST_NOT);//false, true );
 
         q.setMinimumNumberShouldMatch(2); // 2 of 3 optional 
 
@@ -164,12 +157,12 @@
 
         /* one required, one prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);// true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
 
         q.setMinimumNumberShouldMatch(3); // 3 of 4 optional 
 
@@ -180,13 +173,13 @@
 
         /* two required, one prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all",  "all")), true,  false);
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
+        q.add(new TermQuery(new Term("all",  "all")), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
 
         q.setMinimumNumberShouldMatch(3); // 3 of 4 optional 
 
@@ -197,13 +190,13 @@
 
         /* one required, two prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
-        q.add(new TermQuery(new Term("data", "C"  )), false, true );
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "C"  )), BooleanClause.Occur.MUST_NOT);//false, true );
 
         q.setMinimumNumberShouldMatch(3); // 3 of 4 optional 
 
@@ -214,14 +207,14 @@
 
         /* two required, two prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all",  "all")), true,  false);
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
-        q.add(new TermQuery(new Term("data", "C"  )), false, true );
+        q.add(new TermQuery(new Term("all",  "all")), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "C"  )), BooleanClause.Occur.MUST_NOT);//false, true );
 
         q.setMinimumNumberShouldMatch(3); // 3 of 4 optional 
 
@@ -232,14 +225,14 @@
 
         /* two required, two prohibited, some optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all",  "all")), true,  false);
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "5"  )), false, false);
-        q.add(new TermQuery(new Term("data", "4"  )), false, false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, true );
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
-        q.add(new TermQuery(new Term("data", "1"  )), false, false);
-        q.add(new TermQuery(new Term("data", "C"  )), false, true );
+        q.add(new TermQuery(new Term("all",  "all")), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "5"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "4"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST_NOT);//false, true );
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "1"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "C"  )), BooleanClause.Occur.MUST_NOT);//false, true );
 
         q.setMinimumNumberShouldMatch(90); // 90 of 4 optional ?!?!?!
 
@@ -250,10 +243,10 @@
 
         /* two required, two optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all", "all" )), false, false);
-        q.add(new TermQuery(new Term("data", "6"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "3"  )), true,  false);
-        q.add(new TermQuery(new Term("data", "2"  )), false, false);
+        q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "6"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.SHOULD);//false, false);
 
         q.setMinimumNumberShouldMatch(2); // 2 of 2 optional 
 
@@ -264,9 +257,9 @@
 
         /* two required, one optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all", "all" )), true,  false);
-        q.add(new TermQuery(new Term("data", "3"  )), false, false);
-        q.add(new TermQuery(new Term("data", "2"  )), true,  false);
+        q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "3"  )), BooleanClause.Occur.SHOULD);//false, false);
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.MUST);//true,  false);
 
         q.setMinimumNumberShouldMatch(1); // 1 of 1 optional 
 
@@ -277,8 +270,8 @@
 
         /* two required, no optional */
         BooleanQuery q = new BooleanQuery();
-        q.add(new TermQuery(new Term("all", "all" )), true,  false);
-        q.add(new TermQuery(new Term("data", "2"  )), true,  false);
+        q.add(new TermQuery(new Term("all", "all" )), BooleanClause.Occur.MUST);//true,  false);
+        q.add(new TermQuery(new Term("data", "2"  )), BooleanClause.Occur.MUST);//true,  false);
 
         q.setMinimumNumberShouldMatch(1); // 1 of 0 optional 
 
@@ -306,7 +299,7 @@
       };
 
 
-      int tot=0;
+
       // increase number of iterations for more complete testing      
       for (int i=0; i<1000; i++) {
         int lev = rnd.nextInt(maxLev);
@@ -322,7 +315,6 @@
         // will not normalize scores.
         TopDocs top1 = s.search(q1,null,100);
         TopDocs top2 = s.search(q2,null,100);
-        tot+=top2.totalHits;
 
         // The constrained query
         // should be a superset to the unconstrained query.

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestConstantScoreRangeQuery.java Tue Mar 21 07:36:32 2006
@@ -16,19 +16,16 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-
-import org.apache.lucene.store.RAMDirectory;
-import org.apache.lucene.store.Directory;
-
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.Term;
-
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
+
+import java.io.IOException;
 
 public class TestConstantScoreRangeQuery extends BaseTestRangeFilter {
     
@@ -69,10 +66,10 @@
         
         for (int i = 0; i < data.length; i++) {
             Document doc = new Document();
-            doc.add(Field.Keyword("id",String.valueOf(i)));
-            doc.add(Field.Keyword("all","all"));
+            doc.add(new Field("id", String.valueOf(i), Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("id",String.valueOf(i)));
+            doc.add(new Field("all", "all", Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("all","all"));
             if (null != data[i]) {
-                doc.add(Field.Text("data",data[i]));
+                doc.add(new Field("data", data[i], Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("data",data[i]));
             }
             writer.addDocument(doc);
         }
@@ -182,8 +179,8 @@
         // ConstantScoreRangeQuery and make sure hte order is the same
         
         BooleanQuery q = new BooleanQuery();
-        q.add(rq, T, F);
-        q.add(csrq("data","1","6", T, T), T, F);
+        q.add(rq, BooleanClause.Occur.MUST);//T, F);
+        q.add(csrq("data","1","6", T, T), BooleanClause.Occur.MUST);//T, F);
 
         Hits actual = search.search(q);
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDateFilter.java Tue Mar 21 07:36:32 2006
@@ -16,21 +16,17 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.store.RAMDirectory;
+import junit.framework.TestCase;
 import org.apache.lucene.analysis.SimpleAnalyzer;
+import org.apache.lucene.document.DateTools;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.DateField;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.store.RAMDirectory;
 
 import java.io.IOException;
 
-import junit.framework.TestCase;
-
  /**
   * DateFilter JUnit tests.
   *
@@ -59,7 +55,7 @@
 
  	Document doc = new Document();
  	// add time that is in the past
- 	doc.add(new Field("datefield", DateField.timeToString(now - 1000), Field.Store.YES, Field.Index.UN_TOKENIZED));
+ 	doc.add(new Field("datefield", DateTools.timeToString(now - 1000, DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
  	doc.add(new Field("body", "Today is a very sunny day in New York City", Field.Store.YES, Field.Index.TOKENIZED));
   	writer.addDocument(doc);
  	writer.optimize();
@@ -68,12 +64,15 @@
 	IndexSearcher searcher = new IndexSearcher(indexStore);
 
 	// filter that should preserve matches
-	DateFilter df1 = DateFilter.Before("datefield", now);
-
+	//DateFilter df1 = DateFilter.Before("datefield", now);
+    RangeFilter df1 = new RangeFilter("datefield", DateTools.timeToString(now - 2000, DateTools.Resolution.MILLISECOND),
+                                      DateTools.timeToString(now, DateTools.Resolution.MILLISECOND), false, true);
 	// filter that should discard matches
-	DateFilter df2 = DateFilter.Before("datefield", now - 999999);
+	//DateFilter df2 = DateFilter.Before("datefield", now - 999999);
+    RangeFilter df2 = new RangeFilter("datefield", DateTools.timeToString(0, DateTools.Resolution.MILLISECOND),
+                                      DateTools.timeToString(now - 2000, DateTools.Resolution.MILLISECOND), true, false);
 
-	// search something that doesn't exist with DateFilter
+    // search something that doesn't exist with DateFilter
 	Query query1 = new TermQuery(new Term("body", "NoMatchForThis"));
 
 	// search for something that does exists
@@ -117,7 +116,7 @@
 
  	Document doc = new Document();
  	// add time that is in the future
- 	doc.add(new Field("datefield", DateField.timeToString(now + 888888), Field.Store.YES, Field.Index.UN_TOKENIZED));
+ 	doc.add(new Field("datefield", DateTools.timeToString(now + 888888, DateTools.Resolution.MILLISECOND), Field.Store.YES, Field.Index.UN_TOKENIZED));
  	doc.add(new Field("body", "Today is a very sunny day in New York City", Field.Store.YES, Field.Index.TOKENIZED));
   	writer.addDocument(doc);
  	writer.optimize();
@@ -126,12 +125,15 @@
 	IndexSearcher searcher = new IndexSearcher(indexStore);
 
 	// filter that should preserve matches
-	DateFilter df1 = DateFilter.After("datefield", now);
-
+	//DateFilter df1 = DateFilter.After("datefield", now);
+    RangeFilter df1 = new RangeFilter("datefield", DateTools.timeToString(now, DateTools.Resolution.MILLISECOND),
+                                      DateTools.timeToString(now + 999999, DateTools.Resolution.MILLISECOND), true, false);
 	// filter that should discard matches
-	DateFilter df2 = DateFilter.After("datefield", now + 999999);
+	//DateFilter df2 = DateFilter.After("datefield", now + 999999);
+    RangeFilter df2 = new RangeFilter("datefield", DateTools.timeToString(now + 999999, DateTools.Resolution.MILLISECOND),
+                                          DateTools.timeToString(now + 999999999, DateTools.Resolution.MILLISECOND), false, true);
 
-	// search something that doesn't exist with DateFilter
+    // search something that doesn't exist with DateFilter
 	Query query1 = new TermQuery(new Term("body", "NoMatchForThis"));
 
 	// search for something that does exists

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java Tue Mar 21 07:36:32 2006
@@ -17,26 +17,16 @@
  * limitations under the License.
  */
 
+import junit.framework.TestCase;
 import org.apache.lucene.analysis.WhitespaceAnalyzer;
-
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-
-import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
-
-import org.apache.lucene.search.Hits;
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.Query;
-import org.apache.lucene.search.Similarity;
-import org.apache.lucene.search.DefaultSimilarity;
-
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 
-import junit.framework.TestCase;
-
 import java.text.DecimalFormat;
 
 /**
@@ -92,38 +82,38 @@
         // d1 is an "ok" match for:  albino elephant
         {
             Document d1 = new Document();
-            d1.add(Field.Keyword("id", "d1"));
-            d1.add(Field.Text("hed", "elephant"));
-            d1.add(Field.Text("dek", "elephant"));
+            d1.add(new Field("id", "d1", Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("id", "d1"));
+            d1.add(new Field("hed", "elephant", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("hed", "elephant"));
+            d1.add(new Field("dek", "elephant", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("dek", "elephant"));
             writer.addDocument(d1);
         }
 
         // d2 is a "good" match for:  albino elephant
         {
             Document d2 = new Document();
-            d2.add(Field.Keyword("id", "d2"));
-            d2.add(Field.Text("hed", "elephant"));
-            d2.add(Field.Text("dek", "albino"));
-            d2.add(Field.Text("dek", "elephant"));
+            d2.add(new Field("id", "d2", Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("id", "d2"));
+            d2.add(new Field("hed", "elephant", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("hed", "elephant"));
+            d2.add(new Field("dek", "albino", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("dek", "albino"));
+            d2.add(new Field("dek", "elephant", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("dek", "elephant"));
             writer.addDocument(d2);
         }
 
         // d3 is a "better" match for:  albino elephant
         {
             Document d3 = new Document();
-            d3.add(Field.Keyword("id", "d3"));
-            d3.add(Field.Text("hed", "albino"));
-            d3.add(Field.Text("hed", "elephant"));
+            d3.add(new Field("id", "d3", Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("id", "d3"));
+            d3.add(new Field("hed", "albino", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("hed", "albino"));
+            d3.add(new Field("hed", "elephant", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("hed", "elephant"));
             writer.addDocument(d3);
         }
 
         // d4 is the "best" match for:  albino elephant
         {
             Document d4 = new Document();
-            d4.add(Field.Keyword("id", "d4"));
-            d4.add(Field.Text("hed", "albino"));
-            d4.add(Field.Text("hed", "elephant"));
-            d4.add(Field.Text("dek", "albino"));
+            d4.add(new Field("id", "d4", Field.Store.YES, Field.Index.UN_TOKENIZED));//Field.Keyword("id", "d4"));
+            d4.add(new Field("hed", "albino", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("hed", "albino"));
+            d4.add(new Field("hed", "elephant", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("hed", "elephant"));
+            d4.add(new Field("dek", "albino", Field.Store.YES, Field.Index.TOKENIZED));//Field.Text("dek", "albino"));
             writer.addDocument(d4);
         }
 
@@ -241,13 +231,13 @@
             DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.0f);
             q1.add(tq("hed","albino"));
             q1.add(tq("dek","albino"));
-            q.add(q1,true,false);
+            q.add(q1,BooleanClause.Occur.MUST);//true,false);
         }
         {
             DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.0f);
             q2.add(tq("hed","elephant"));
             q2.add(tq("dek","elephant"));
-            q.add(q2,true,false);
+            q.add(q2, BooleanClause.Occur.MUST);//true,false);
         }
 
 
@@ -275,13 +265,13 @@
             DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.0f);
             q1.add(tq("hed","albino"));
             q1.add(tq("dek","albino"));
-            q.add(q1,false,false);
+            q.add(q1, BooleanClause.Occur.SHOULD);//false,false);
         }
         {
             DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.0f);
             q2.add(tq("hed","elephant"));
             q2.add(tq("dek","elephant"));
-            q.add(q2,false,false);
+            q.add(q2, BooleanClause.Occur.SHOULD);//false,false);
         }
 
 
@@ -314,13 +304,13 @@
             DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
             q1.add(tq("hed","albino"));
             q1.add(tq("dek","albino"));
-            q.add(q1,false,false);
+            q.add(q1, BooleanClause.Occur.SHOULD);//false,false);
         }
         {
             DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.01f);
             q2.add(tq("hed","elephant"));
             q2.add(tq("dek","elephant"));
-            q.add(q2,false,false);
+            q.add(q2, BooleanClause.Occur.SHOULD);//false,false);
         }
 
 
@@ -372,13 +362,13 @@
             DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
             q1.add(tq("hed","albino", 1.5f));
             q1.add(tq("dek","albino"));
-            q.add(q1,false,false);
+            q.add(q1, BooleanClause.Occur.SHOULD);//false,false);
         }
         {
             DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.01f);
             q2.add(tq("hed","elephant", 1.5f));
             q2.add(tq("dek","elephant"));
-            q.add(q2,false,false);
+            q.add(q2, BooleanClause.Occur.SHOULD);//false,false);
         }
 
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMatchAllDocsQuery.java Tue Mar 21 07:36:32 2006
@@ -60,7 +60,7 @@
     assertEquals(1, hits.length());
 
     // delete a document:
-    is.getIndexReader().delete(0);
+    is.getIndexReader().deleteDocument(0);
     hits = is.search(new MatchAllDocsQuery());
     assertEquals(2, hits.length());
     

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcher.java Tue Mar 21 07:36:32 2006
@@ -99,7 +99,8 @@
         writerB.close();
 
         // creating the query
-        Query query = QueryParser.parse("handle:1", "fulltext", new StandardAnalyzer());
+        QueryParser parser = new QueryParser("fulltext", new StandardAnalyzer());
+        Query query = parser.parse("handle:1");
 
         // building the searchables
         Searcher[] searchers = new Searcher[2];
@@ -156,7 +157,7 @@
         // deleting the document just added, this will cause a different exception to take place
         Term term = new Term("id", "doc1");
         IndexReader readerB = IndexReader.open(indexStoreB);
-        readerB.delete(term);
+        readerB.deleteDocuments(term);
         readerB.close();
 
         // optimizing the index with the writer

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestMultiSearcherRanking.java Tue Mar 21 07:36:32 2006
@@ -16,10 +16,7 @@
  * limitations under the License.
  */
 
-import java.io.IOException;
-
 import junit.framework.TestCase;
-
 import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
@@ -29,6 +26,8 @@
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 
+import java.io.IOException;
+
 /**
  * Tests {@link MultiSearcher} ranking, i.e. makes sure this bug is fixed:
  * http://issues.apache.org/bugzilla/show_bug.cgi?id=31841
@@ -88,8 +87,8 @@
   private void checkQuery(String queryStr) throws IOException, ParseException {
     // check result hit ranking
     if(verbose) System.out.println("Query: " + queryStr);
-    Query query = QueryParser.parse(queryStr, FIELD_NAME,
-        new StandardAnalyzer());
+      QueryParser queryParser = new QueryParser(FIELD_NAME, new StandardAnalyzer());
+    Query query = queryParser.parse(queryStr);
     Hits multiSearcherHits = multiSearcher.search(query);
     Hits singleSearcherHits = singleSearcher.search(query);
     assertEquals(multiSearcherHits.length(), singleSearcherHits.length());

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestNot.java Tue Mar 21 07:36:32 2006
@@ -47,7 +47,8 @@
     writer.close();
 
     Searcher searcher = new IndexSearcher(store);
-    Query query = QueryParser.parse("a NOT b", "field", new SimpleAnalyzer());
+      QueryParser parser = new QueryParser("field", new SimpleAnalyzer());
+    Query query = parser.parse("a NOT b");
     //System.out.println(query);
     Hits hits = searcher.search(query);
     assertEquals(0, hits.length());

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java
URL: http://svn.apache.org/viewcvs/lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java?rev=387550&r1=387549&r2=387550&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestPhrasePrefixQuery.java Tue Mar 21 07:36:32 2006
@@ -16,17 +16,15 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.index.Term;
-import org.apache.lucene.index.TermEnum;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.index.IndexWriter;
-import org.apache.lucene.store.RAMDirectory;
+import junit.framework.TestCase;
 import org.apache.lucene.analysis.SimpleAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-
-import junit.framework.TestCase;
+import org.apache.lucene.index.IndexReader;
+import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.Term;
+import org.apache.lucene.index.TermEnum;
+import org.apache.lucene.store.RAMDirectory;
 
 import java.io.IOException;
 import java.util.LinkedList;
@@ -73,8 +71,10 @@
 
         IndexSearcher searcher = new IndexSearcher(indexStore);
 
-        PhrasePrefixQuery query1 = new PhrasePrefixQuery();
-        PhrasePrefixQuery query2 = new PhrasePrefixQuery();
+        //PhrasePrefixQuery query1 = new PhrasePrefixQuery();
+        MultiPhraseQuery query1 = new MultiPhraseQuery();
+        //PhrasePrefixQuery query2 = new PhrasePrefixQuery();
+        MultiPhraseQuery query2 = new MultiPhraseQuery();
         query1.add(new Term("body", "blueberry"));
         query2.add(new Term("body", "strawberry"));
 



Mime
View raw message