lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r824697 - in /lucene/java/trunk: ./ contrib/instantiated/src/test/org/apache/lucene/store/instantiated/ contrib/remote/src/test/org/apache/lucene/search/ src/java/org/apache/lucene/search/ src/test/org/apache/lucene/search/
Date Tue, 13 Oct 2009 11:18:26 GMT
Author: uschindler
Date: Tue Oct 13 11:18:25 2009
New Revision: 824697

URL: http://svn.apache.org/viewvc?rev=824697&view=rev
Log:
LUCENE-1972: Remove deprecated ExtendedFieldCache, custom and auto caches, SortField.AUTO, deprecated custom sort, deprecated sorting HitCollectors, deprecated TopDocs HitCollectors, legacy search

Removed:
    lucene/java/trunk/src/java/org/apache/lucene/search/ExtendedFieldCache.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldSortedHitQueue.java
    lucene/java/trunk/src/java/org/apache/lucene/search/QueryFilter.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ScoreDocComparator.java
    lucene/java/trunk/src/java/org/apache/lucene/search/SortComparator.java
    lucene/java/trunk/src/java/org/apache/lucene/search/SortComparatorSource.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TopDocCollector.java
    lucene/java/trunk/src/java/org/apache/lucene/search/TopFieldDocCollector.java
Modified:
    lucene/java/trunk/CHANGES.txt
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
    lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
    lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestRealTime.java
    lucene/java/trunk/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldCache.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java
    lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java
    lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
    lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java
    lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
    lucene/java/trunk/src/test/org/apache/lucene/search/TestStressSort.java

Modified: lucene/java/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/java/trunk/CHANGES.txt?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/CHANGES.txt (original)
+++ lucene/java/trunk/CHANGES.txt Tue Oct 13 11:18:25 2009
@@ -56,6 +56,11 @@
 * LUCENE-1975: Remove deprecated SpanQuery.getTerms() and generify 
   Query.extractTerms(Set<Term>) (Michael Busch)
 
+* LUCENE-1972: Remove deprecated ExtendedFieldCache, custom and auto
+  caches, SortField.AUTO, deprecated custom sort, deprecated sorting
+  HitCollectors, deprecated TopDocs HitCollectors, legacy search
+  (Uwe Schindler)
+
 Bug fixes
 
 * LUCENE-1951: When the text provided to WildcardQuery has no wildcard

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Tue Oct 13 11:18:25 2009
@@ -42,7 +42,7 @@
   <property name="Name" value="Lucene"/>
   <property name="dev.version" value="3.0-dev"/>
   <property name="version" value="${dev.version}"/>
-  <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091013a"/>
+  <property name="compatibility.tag" value="lucene_2_9_back_compat_tests_20091013b"/>
   <property name="spec.version" value="${version}"/>	
   <property name="year" value="2000-${current.year}"/>
   <property name="final.name" value="lucene-${name}-${version}"/>

Modified: lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java (original)
+++ lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestEmptyIndex.java Tue Oct 13 11:18:25 2009
@@ -23,7 +23,7 @@
 import org.apache.lucene.index.TermEnum;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocCollector;
+import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 
@@ -39,10 +39,9 @@
     IndexReader r = new InstantiatedIndexReader(ii);
     IndexSearcher s = new IndexSearcher(r);
 
-    TopDocCollector c = new TopDocCollector(1);
-    s.search(new TermQuery(new Term("foo", "bar")), c);
+    TopDocs td = s.search(new TermQuery(new Term("foo", "bar")), 1);
 
-    assertEquals(0, c.getTotalHits());
+    assertEquals(0, td.totalHits);
 
     s.close();
     r.close();

Modified: lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java (original)
+++ lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestIndicesEquals.java Tue Oct 13 11:18:25 2009
@@ -43,8 +43,6 @@
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TermQuery;
-import org.apache.lucene.search.TopDocCollector;
-import org.apache.lucene.search.TopScoreDocCollector;
 import org.apache.lucene.util.AttributeImpl;
 
 /**

Modified: lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestRealTime.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestRealTime.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestRealTime.java (original)
+++ lucene/java/trunk/contrib/instantiated/src/test/org/apache/lucene/store/instantiated/TestRealTime.java Tue Oct 13 11:18:25 2009
@@ -17,12 +17,12 @@
 
 import junit.framework.TestCase;
 import org.apache.lucene.search.IndexSearcher;
-import org.apache.lucene.search.TopDocCollector;
-import org.apache.lucene.search.HitCollector;
 import org.apache.lucene.search.TermQuery;
+import org.apache.lucene.search.Scorer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.index.Term;
+import org.apache.lucene.index.IndexReader;
 
 /**
  * Assert that the content of an index 
@@ -62,9 +62,12 @@
 
   }
 
-  public static class Collector extends HitCollector {
+  public static class Collector extends org.apache.lucene.search.Collector {
     private int hits = 0;
-    public void collect(int doc, float score) {
+    public void setScorer(Scorer scorer) {}
+    public void setNextReader(IndexReader reader, int docBase) {}
+    public boolean acceptsDocsOutOfOrder() { return true; }
+    public void collect(int doc) {
       hits++;
     }
   }

Modified: lucene/java/trunk/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java (original)
+++ lucene/java/trunk/contrib/remote/src/test/org/apache/lucene/search/TestRemoteSort.java Tue Oct 13 11:18:25 2009
@@ -236,29 +236,6 @@
     runMultiSorts(multi, true); // this runs on the full index
   }
 
-  // test custom search when remote
-  /* rewrite with new API
-  public void testRemoteCustomSort() throws Exception {
-    Searchable searcher = getRemote();
-    MultiSearcher multi = new MultiSearcher (new Searchable[] { searcher });
-    sort.setSort (new SortField ("custom", SampleComparable.getComparatorSource()));
-    assertMatches (multi, queryX, sort, "CAIEG");
-    sort.setSort (new SortField ("custom", SampleComparable.getComparatorSource(), true));
-    assertMatches (multi, queryY, sort, "HJDBF");
-
-    assertSaneFieldCaches(getName() + " ComparatorSource");
-    FieldCache.DEFAULT.purgeAllCaches();
-
-    SortComparator custom = SampleComparable.getComparator();
-    sort.setSort (new SortField ("custom", custom));
-    assertMatches (multi, queryX, sort, "CAIEG");
-    sort.setSort (new SortField ("custom", custom, true));
-    assertMatches (multi, queryY, sort, "HJDBF");
-
-    assertSaneFieldCaches(getName() + " Comparator");
-    FieldCache.DEFAULT.purgeAllCaches();
-  }*/
-
   // test that the relevancy scores are the same even if
   // hits are sorted
   public void testNormalizedScores() throws Exception {
@@ -283,32 +260,32 @@
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
 
-    sort.setSort ("int");
+    sort.setSort (new SortField("int", SortField.INT));
     assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
 
-    sort.setSort ("float");
+    sort.setSort (new SortField("float", SortField.FLOAT));
     assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
 
-    sort.setSort ("string");
+    sort.setSort (new SortField("string", SortField.STRING));
     assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
 
-    sort.setSort (new String[] {"int","float"});
+    sort.setSort (new SortField("int", SortField.INT), new SortField("float", SortField.FLOAT));
     assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
 
-    sort.setSort (new SortField[] { new SortField ("int", SortField.INT, true), new SortField (null, SortField.DOC, true) });
+    sort.setSort (new SortField ("int", SortField.INT, true), new SortField (null, SortField.DOC, true) );
     assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
 
-    sort.setSort (new String[] {"float","string"});
+    sort.setSort (new SortField("float", SortField.FLOAT), new SortField("string", SortField.STRING));
     assertSameValues (scoresX, getScores (remote.search (queryX, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresY, getScores (remote.search (queryY, null, 1000, sort).scoreDocs, remote));
     assertSameValues (scoresA, getScores (remote.search (queryA, null, 1000, sort).scoreDocs, remote));
@@ -324,52 +301,48 @@
     expected = isFull ? "IDHFGJABEC" : "IDHFGJAEBC";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort(new SortField[] {new SortField ("int", SortField.INT), SortField.FIELD_DOC});
+    sort.setSort(new SortField ("int", SortField.INT), SortField.FIELD_DOC);
     expected = isFull ? "IDHFGJABEC" : "IDHFGJAEBC";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort("int");
-    expected = isFull ? "IDHFGJABEC" : "IDHFGJAEBC";
-    assertMatches(multi, queryA, sort, expected);
-
-    sort.setSort(new SortField[] {new SortField ("float", SortField.FLOAT), SortField.FIELD_DOC});
+    sort.setSort(new SortField ("float", SortField.FLOAT), SortField.FIELD_DOC);
     assertMatches(multi, queryA, sort, "GDHJCIEFAB");
 
-    sort.setSort("float");
+    sort.setSort(new SortField("float", SortField.FLOAT));
     assertMatches(multi, queryA, sort, "GDHJCIEFAB");
 
-    sort.setSort("string");
+    sort.setSort(new SortField("string", SortField.STRING));
     assertMatches(multi, queryA, sort, "DJAIHGFEBC");
 
-    sort.setSort("int", true);
+    sort.setSort(new SortField ("int", SortField.INT, true));
     expected = isFull ? "CABEJGFHDI" : "CAEBJGFHDI";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort("float", true);
+    sort.setSort(new SortField ("float", SortField.FLOAT, true));
     assertMatches(multi, queryA, sort, "BAFECIJHDG");
 
-    sort.setSort("string", true);
+    sort.setSort(new SortField ("string", SortField.STRING, true));
     assertMatches(multi, queryA, sort, "CBEFGHIAJD");
 
-    sort.setSort(new String[] {"int","float"});
+    sort.setSort(new SortField ("int", SortField.INT), new SortField ("float", SortField.FLOAT));
     assertMatches(multi, queryA, sort, "IDHFGJEABC");
 
-    sort.setSort(new String[] {"float","string"});
+    sort.setSort(new SortField ("float", SortField.FLOAT), new SortField ("string", SortField.STRING));
     assertMatches(multi, queryA, sort, "GDHJICEFAB");
 
-    sort.setSort("int");
+    sort.setSort(new SortField ("int", SortField.INT));
     assertMatches(multi, queryF, sort, "IZJ");
 
-    sort.setSort("int", true);
+    sort.setSort(new SortField ("int", SortField.INT, true));
     assertMatches(multi, queryF, sort, "JZI");
 
-    sort.setSort("float");
+    sort.setSort(new SortField ("float", SortField.FLOAT));
     assertMatches(multi, queryF, sort, "ZJI");
 
-    sort.setSort("string");
+    sort.setSort(new SortField ("string", SortField.STRING));
     assertMatches(multi, queryF, sort, "ZJI");
 
-    sort.setSort("string", true);
+    sort.setSort(new SortField ("string", SortField.STRING, true));
     assertMatches(multi, queryF, sort, "IJZ");
 
     // up to this point, all of the searches should have "sane" 
@@ -378,10 +351,10 @@
     // next we'll check an alternate Locale for string, so purge first
     FieldCache.DEFAULT.purgeAllCaches();
 
-    sort.setSort(new SortField[] { new SortField ("string", Locale.US) });
+    sort.setSort(new SortField ("string", Locale.US) );
     assertMatches(multi, queryA, sort, "DJAIHGFEBC");
 
-    sort.setSort(new SortField[] { new SortField ("string", Locale.US, true)});
+    sort.setSort(new SortField ("string", Locale.US, true));
     assertMatches(multi, queryA, sort, "CBEFGHIAJD");
 
     assertSaneFieldCaches(getName() + " Locale.US");

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldCache.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldCache.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldCache.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldCache.java Tue Oct 13 11:18:25 2009
@@ -483,39 +483,6 @@
   public StringIndex getStringIndex (IndexReader reader, String field)
   throws IOException;
 
-  /** Checks the internal cache for an appropriate entry, and if
-   * none is found reads <code>field</code> to see if it contains integers, longs, floats
-   * or strings, and then calls one of the other methods in this class to get the
-   * values.  For string values, a StringIndex is returned.  After
-   * calling this method, there is an entry in the cache for both
-   * type <code>AUTO</code> and the actual found type.
-   * @param reader  Used to get field values.
-   * @param field   Which field contains the values.
-   * @return int[], long[], float[] or StringIndex.
-   * @throws IOException  If any error occurs.
-   * @deprecated Please specify the exact type, instead.
-   *  Especially, guessing does <b>not</b> work with the new
-   *  {@link NumericField} type.
-   */
-  public Object getAuto (IndexReader reader, String field)
-  throws IOException;
-
-  /** Checks the internal cache for an appropriate entry, and if none
-   * is found reads the terms out of <code>field</code> and calls the given SortComparator
-   * to get the sort values.  A hit in the cache will happen if <code>reader</code>,
-   * <code>field</code>, and <code>comparator</code> are the same (using <code>equals()</code>)
-   * as a previous call to this method.
-   * @param reader  Used to get field values.
-   * @param field   Which field contains the values.
-   * @param comparator Used to convert terms into something to sort by.
-   * @return Array of sort objects, one for each document.
-   * @throws IOException  If any error occurs.
-   * @deprecated Please implement {@link
-   * FieldComparatorSource} directly, instead.
-   */
-  public Comparable[] getCustom (IndexReader reader, String field, SortComparator comparator)
-  throws IOException;
-
   /**
    * EXPERT: A unique Identifier/Description for each item in the FieldCache. 
    * Can be useful for logging/debugging.

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldCacheImpl.java Tue Oct 13 11:18:25 2009
@@ -43,8 +43,7 @@
  *
  * @since   lucene 1.4
  */
- // TODO: change interface to FieldCache in 3.0 when removed
-class FieldCacheImpl implements ExtendedFieldCache {
+class FieldCacheImpl implements FieldCache {
 	
   private Map caches;
   FieldCacheImpl() {
@@ -60,8 +59,6 @@
     caches.put(Double.TYPE, new DoubleCache(this));
     caches.put(String.class, new StringCache(this));
     caches.put(StringIndex.class, new StringIndexCache(this));
-    caches.put(Comparable.class, new CustomCache(this));
-    caches.put(Object.class, new AutoCache(this));
   }
 
   public void purgeAllCaches() {
@@ -524,12 +521,6 @@
     return (long[]) ((Cache)caches.get(Long.TYPE)).get(reader, new Entry(field, parser));
   }
 
-  /** @deprecated Will be removed in 3.0, this is for binary compatibility only */
-  public long[] getLongs(IndexReader reader, String field, ExtendedFieldCache.LongParser parser)
-      throws IOException {
-    return (long[]) ((Cache)caches.get(Long.TYPE)).get(reader, new Entry(field, parser));
-  }
-
   static final class LongCache extends Cache {
     LongCache(FieldCache wrapper) {
       super(wrapper);
@@ -585,12 +576,6 @@
     return (double[]) ((Cache)caches.get(Double.TYPE)).get(reader, new Entry(field, parser));
   }
 
-  /** @deprecated Will be removed in 3.0, this is for binary compatibility only */
-  public double[] getDoubles(IndexReader reader, String field, ExtendedFieldCache.DoubleParser parser)
-      throws IOException {
-    return (double[]) ((Cache)caches.get(Double.TYPE)).get(reader, new Entry(field, parser));
-  }
-
   static final class DoubleCache extends Cache {
     DoubleCache(FieldCache wrapper) {
       super(wrapper);
@@ -736,109 +721,6 @@
     }
   };
 
-  /** The pattern used to detect integer values in a field */
-  /** removed for java 1.3 compatibility
-   protected static final Pattern pIntegers = Pattern.compile ("[0-9\\-]+");
-   **/
-
-  /** The pattern used to detect float values in a field */
-  /**
-   * removed for java 1.3 compatibility
-   * protected static final Object pFloats = Pattern.compile ("[0-9+\\-\\.eEfFdD]+");
-   */
-
-	// inherit javadocs
-  public Object getAuto(IndexReader reader, String field) throws IOException {
-    return ((Cache)caches.get(Object.class)).get(reader, new Entry(field, (Parser)null));
-  }
-
-  /**
-   * @deprecated Please specify the exact type, instead.
-   *  Especially, guessing does <b>not</b> work with the new
-   *  {@link NumericField} type.
-   */
-  static final class AutoCache extends Cache {
-    AutoCache(FieldCache wrapper) {
-      super(wrapper);
-    }
-
-    protected Object createValue(IndexReader reader, Entry entryKey)
-        throws IOException {
-      String field = StringHelper.intern((String) entryKey.field);
-      TermEnum enumerator = reader.terms (new Term (field));
-      try {
-        Term term = enumerator.term();
-        if (term == null) {
-          throw new RuntimeException ("no terms in field " + field + " - cannot determine type");
-        }
-        Object ret = null;
-        if (term.field() == field) {
-          String termtext = term.text().trim();
-
-          try {
-            Integer.parseInt (termtext);
-            ret = wrapper.getInts (reader, field);
-          } catch (NumberFormatException nfe1) {
-            try {
-              Long.parseLong(termtext);
-              ret = wrapper.getLongs (reader, field);
-            } catch (NumberFormatException nfe2) {
-              try {
-                Float.parseFloat (termtext);
-                ret = wrapper.getFloats (reader, field);
-              } catch (NumberFormatException nfe3) {
-                ret = wrapper.getStringIndex (reader, field);
-              }
-            }
-          }          
-        } else {
-          throw new RuntimeException ("field \"" + field + "\" does not appear to be indexed");
-        }
-        return ret;
-      } finally {
-        enumerator.close();
-      }
-    }
-  };
-
-  /** @deprecated */
-  public Comparable[] getCustom(IndexReader reader, String field,
-      SortComparator comparator) throws IOException {
-    return (Comparable[]) ((Cache)caches.get(Comparable.class)).get(reader, new Entry(field, comparator));
-  }
-
-  /** @deprecated */
-  static final class CustomCache extends Cache {
-    CustomCache(FieldCache wrapper) {
-      super(wrapper);
-    }
-
-    protected Object createValue(IndexReader reader, Entry entryKey)
-        throws IOException {
-      Entry entry = (Entry) entryKey;
-      String field = entry.field;
-      SortComparator comparator = (SortComparator) entry.custom;
-      final Comparable[] retArray = new Comparable[reader.maxDoc()];
-      TermDocs termDocs = reader.termDocs();
-      TermEnum termEnum = reader.terms (new Term (field));
-      try {
-        do {
-          Term term = termEnum.term();
-          if (term==null || term.field() != field) break;
-          Comparable termval = comparator.getComparable (term.text());
-          termDocs.seek (termEnum);
-          while (termDocs.next()) {
-            retArray[termDocs.doc()] = termval;
-          }
-        } while (termEnum.next());
-      } finally {
-        termDocs.close();
-        termEnum.close();
-      }
-      return retArray;
-    }
-  };
-
   private volatile PrintStream infoStream;
 
   public void setInfoStream(PrintStream stream) {

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldDocSortedHitQueue.java Tue Oct 13 11:18:25 2009
@@ -33,8 +33,6 @@
 class FieldDocSortedHitQueue
 extends PriorityQueue<FieldDoc> {
 
-	// this cannot contain AUTO fields - any AUTO fields should
-	// have been resolved by the time this class is used.
 	volatile SortField[] fields;
 
 	// used in the case where the fields are sorted by locale
@@ -63,10 +61,8 @@
 	 * @param fields
 	 */
 	synchronized void setFields (SortField[] fields) {
-		if (this.fields == null) {
-			this.fields = fields;
-			this.collators = hasCollators (fields);
-		}
+		this.fields = fields;
+		this.collators = hasCollators (fields);
 	}
 
 
@@ -174,13 +170,6 @@
 					c = docA.fields[i].compareTo (docB.fields[i]);
 					break;
         }
-        case SortField.AUTO:{
-					// we cannot handle this - even if we determine the type of object (Float or
-					// Integer), we don't necessarily know how to compare them (both SCORE and
-					// FLOAT contain floats, but are sorted opposite of each other). Before
-					// we get here, each AUTO should have been replaced with its actual value.
-					throw new RuntimeException ("FieldDocSortedHitQueue cannot use an AUTO SortField");
-        }
         default:{
 					throw new RuntimeException ("invalid SortField type: "+type);
         }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/FieldValueHitQueue.java Tue Oct 13 11:18:25 2009
@@ -26,11 +26,6 @@
  * Uses <code>FieldCache.DEFAULT</code> for maintaining
  * internal term lookup tables.
  * 
- * This class will not resolve SortField.AUTO types, and expects the type
- * of all SortFields used for construction to already have been resolved. 
- * {@link SortField#detectFieldType(IndexReader, String)} is a utility method which
- * may be used for field type detection.
- *
  * <b>NOTE:</b> This API is experimental and might change in
  * incompatible ways in the next release.
  *
@@ -74,8 +69,6 @@
       }
 
       SortField field = fields[0];
-      // AUTO is resolved before we are called
-      assert field.getType() != SortField.AUTO;
       comparator = field.getComparator(size, 0);
       oneReverseMul = field.reverse ? -1 : 1;
 
@@ -123,9 +116,6 @@
       for (int i = 0; i < numComparators; ++i) {
         SortField field = fields[i];
 
-        // AUTO is resolved before we are called
-        assert field.getType() != SortField.AUTO;
-
         reverseMul[i] = field.reverse ? -1 : 1;
         comparators[i] = field.getComparator(size, i);
       }

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/IndexSearcher.java Tue Oct 13 11:18:25 2009
@@ -173,40 +173,10 @@
       throws IOException {
     
     SortField[] fields = sort.fields;
-    boolean legacy = false;
     for(int i = 0; i < fields.length; i++) {
       SortField field = fields[i];
       String fieldname = field.getField();
       int type = field.getType();
-      // Resolve AUTO into its true type
-      if (type == SortField.AUTO) {
-        int autotype = SortField.detectFieldType(reader, fieldname);
-        if (autotype == SortField.STRING) {
-          fields[i] = new SortField (fieldname, field.getLocale(), field.getReverse());
-        } else {
-          fields[i] = new SortField (fieldname, autotype, field.getReverse());
-        }
-      }
-
-      if (field.getUseLegacySearch()) {
-        legacy = true;
-      }
-    }
-    
-    if (legacy) {
-      // Search the single top-level reader
-      TopDocCollector collector = new TopFieldDocCollector(reader, sort, nDocs);
-      HitCollectorWrapper hcw = new HitCollectorWrapper(collector);
-      hcw.setNextReader(reader, 0);
-      if (filter == null) {
-        Scorer scorer = weight.scorer(reader, true, true);
-        if (scorer != null) {
-          scorer.score(hcw);
-        }
-      } else {
-        searchWithFilter(reader, weight, filter, hcw);
-      }
-      return (TopFieldDocs) collector.topDocs();
     }
     
     TopFieldCollector collector = TopFieldCollector.create(sort, nDocs,

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/ParallelMultiSearcher.java Tue Oct 13 11:18:25 2009
@@ -240,9 +240,6 @@
       this.ioe = ioe;
     }
     if (ioe == null) {
-      // if we are sorting by fields, we need to tell the field sorted hit queue
-      // the actual type of fields, in case the original list contained AUTO.
-      // if the searchable returns null for fields, we'll have problems.
       if (sort != null) {
         TopFieldDocs docsFields = (TopFieldDocs) docs;
         // If one of the Sort fields is FIELD_DOC, need to fix its values, so that

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/Sort.java Tue Oct 13 11:18:25 2009
@@ -123,99 +123,23 @@
     this(SortField.FIELD_SCORE);
   }
 
-  /**
-   * Sorts by the terms in <code>field</code> then by index order (document
-   * number). The type of value in <code>field</code> is determined
-   * automatically.
-   * 
-   * @see SortField#AUTO
-   * @deprecated Please specify the type explicitly by
-   * first creating a {@link SortField} and then use {@link
-   * #Sort(SortField)}
-   */
-  public Sort(String field) {
-    setSort(field, false);
-  }
-
-  /**
-   * Sorts possibly in reverse by the terms in <code>field</code> then by
-   * index order (document number). The type of value in <code>field</code> is
-   * determined automatically.
-   * 
-   * @see SortField#AUTO
-   * @deprecated Please specify the type explicitly by
-   * first creating a {@link SortField} and then use {@link
-   * #Sort(SortField)}
-   */
-  public Sort(String field, boolean reverse) {
-    setSort(field, reverse);
-  }
-
-  /**
-   * Sorts in succession by the terms in each field. The type of value in
-   * <code>field</code> is determined automatically.
-   * 
-   * @see SortField#AUTO
-   * @deprecated Please specify the type explicitly by
-   * first creating {@link SortField}s and then use {@link
-   * #Sort(SortField[])}
-   */
-  public Sort(String[] fields) {
-    setSort(fields);
-  }
-
   /** Sorts by the criteria in the given SortField. */
   public Sort(SortField field) {
     setSort(field);
   }
 
   /** Sorts in succession by the criteria in each SortField. */
-  public Sort(SortField[] fields) {
+  public Sort(SortField... fields) {
     setSort(fields);
   }
 
-  /**
-   * Sets the sort to the terms in <code>field</code> then by index order
-   * (document number).
-   * @deprecated Please specify the type explicitly by
-   * first creating a {@link SortField} and then use {@link
-   * #setSort(SortField)}
-   */
-  public final void setSort(String field) {
-    setSort(field, false);
-  }
-
-  /**
-   * Sets the sort to the terms in <code>field</code> possibly in reverse,
-   * then by index order (document number).
-   * @deprecated Please specify the type explicitly by
-   * first creating a {@link SortField} and then use {@link
-   * #setSort(SortField)}
-   */
-  public void setSort(String field, boolean reverse) {
-    fields = new SortField[] { new SortField(field, SortField.AUTO, reverse) };
-  }
-
-  /** Sets the sort to the terms in each field in succession.
-   * @deprecated Please specify the type explicitly by
-   * first creating {@link SortField}s and then use {@link
-   * #setSort(SortField[])} */
-  public void setSort(String[] fieldnames) {
-    final int n = fieldnames.length;
-    SortField[] nfields = new SortField[n];
-    for (int i = 0; i < n; ++i) {
-      nfields[i] = new SortField(fieldnames[i], SortField.AUTO);
-    }
-    fields = nfields;
-  }
-
   /** Sets the sort to the given criteria. */
   public void setSort(SortField field) {
     this.fields = new SortField[] { field };
   }
 
   /** Sets the sort to the given criteria in succession. */
-  public void setSort(SortField[] fields) {
+  public void setSort(SortField... fields) {
     this.fields = fields;
   }
   

Modified: lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java (original)
+++ lucene/java/trunk/src/java/org/apache/lucene/search/SortField.java Tue Oct 13 11:18:25 2009
@@ -47,15 +47,7 @@
    * values are at the front. */
   public static final int DOC = 1;
 
-  /** Guess type of sort based on field contents.  A regular expression is used
-   * to look at the first term indexed for the field and determine if it
-   * represents an integer number, a floating point number, or just arbitrary
-   * string characters.
-   * @deprecated Please specify the exact type, instead.
-   *  Especially, guessing does <b>not</b> work with the new
-   *  {@link NumericField} type.
-   */
-  public static final int AUTO = 2;
+  // reserved, in Lucene 2.9, there was a constant: AUTO = 2;
 
   /** Sort using term values as Strings.  Sort values are String and lower
    * values are at the front. */
@@ -106,10 +98,9 @@
   public static final SortField FIELD_DOC = new SortField (null, DOC);
 
   private String field;
-  private int type = AUTO;  // defaults to determining type dynamically
+  private int type;  // defaults to determining type dynamically
   private Locale locale;    // defaults to "natural order" (no Locale)
   boolean reverse = false;  // defaults to natural order
-  private SortComparatorSource factory;
   private FieldCache.Parser parser;
 
   // Used for CUSTOM sort
@@ -117,27 +108,6 @@
 
   private boolean useLegacy = false; // remove in Lucene 3.0
 
-  /** Creates a sort by terms in the given field where the type of term value
-   * is determined dynamically ({@link #AUTO AUTO}).
-   * @param field Name of field to sort by, cannot be
-   * <code>null</code>.
-   * @deprecated Please specify the exact type instead.
-   */
-  public SortField (String field) {
-    initFieldType(field, AUTO);
-  }
-
-  /** Creates a sort, possibly in reverse, by terms in the given field where
-   * the type of term value is determined dynamically ({@link #AUTO AUTO}).
-   * @param field Name of field to sort by, cannot be <code>null</code>.
-   * @param reverse True if natural order should be reversed.
-   * @deprecated Please specify the exact type instead.
-   */
-  public SortField (String field, boolean reverse) {
-    initFieldType(field, AUTO);
-    this.reverse = reverse;
-  }
-
   /** Creates a sort by terms in the given field with the type of term
    * values explicitly given.
    * @param field  Name of field to sort by.  Can be <code>null</code> if
@@ -223,17 +193,6 @@
   /** Creates a sort with a custom comparison function.
    * @param field Name of field to sort by; cannot be <code>null</code>.
    * @param comparator Returns a comparator for sorting hits.
-   * @deprecated use SortField (String field, FieldComparatorSource comparator)
-   */
-  public SortField (String field, SortComparatorSource comparator) {
-    initFieldType(field, CUSTOM);
-    setUseLegacySearch(true);
-    this.factory = comparator;
-  }
-  
-  /** Creates a sort with a custom comparison function.
-   * @param field Name of field to sort by; cannot be <code>null</code>.
-   * @param comparator Returns a comparator for sorting hits.
    */
   public SortField (String field, FieldComparatorSource comparator) {
     initFieldType(field, CUSTOM);
@@ -244,19 +203,6 @@
    * @param field Name of field to sort by; cannot be <code>null</code>.
    * @param comparator Returns a comparator for sorting hits.
    * @param reverse True if natural order should be reversed.
-   * @deprecated use SortField (String field, FieldComparatorSource comparator, boolean reverse)
-   */
-  public SortField (String field, SortComparatorSource comparator, boolean reverse) {
-    initFieldType(field, CUSTOM);
-    setUseLegacySearch(true);
-    this.reverse = reverse;
-    this.factory = comparator;
-  }
-  
-  /** Creates a sort, possibly in reverse, with a custom comparison function.
-   * @param field Name of field to sort by; cannot be <code>null</code>.
-   * @param comparator Returns a comparator for sorting hits.
-   * @param reverse True if natural order should be reversed.
    */
   public SortField (String field, FieldComparatorSource comparator, boolean reverse) {
     initFieldType(field, CUSTOM);
@@ -285,7 +231,7 @@
   }
 
   /** Returns the type of contents in the field.
-   * @return One of the constants SCORE, DOC, AUTO, STRING, INT or FLOAT.
+   * @return One of the constants SCORE, DOC, STRING, INT or FLOAT.
    */
   public int getType() {
     return type;
@@ -314,37 +260,6 @@
     return reverse;
   }
 
-  /**
-   * @deprecated use {@link #getComparatorSource()}
-   */
-  public SortComparatorSource getFactory() {
-    return factory;
-  }
-  
-  public FieldComparatorSource getComparatorSource() {
-    return comparatorSource;
-  }
-  
-  /**
-   * Use legacy IndexSearch implementation: search with a DirectoryReader rather
-   * than passing a single hit collector to multiple SegmentReaders.
-   * 
-   * @param legacy true for legacy behavior
-   * @deprecated will be removed in Lucene 3.0.
-   */
-  public void setUseLegacySearch(boolean legacy) {
-    this.useLegacy = legacy;
-  }
-  
-  /**
-   * @return if true, IndexSearch will use legacy sorting search implementation.
-   * eg. multiple Priority Queues.
-   * @deprecated will be removed in Lucene 3.0.
-   */
-  public boolean getUseLegacySearch() {
-    return this.useLegacy;
-  }
-
   public String toString() {
     StringBuilder buffer = new StringBuilder();
     switch (type) {
@@ -356,10 +271,6 @@
         buffer.append("<doc>");
         break;
 
-      case AUTO:
-        buffer.append("<auto: \"").append(field).append("\">");
-        break;
-
       case STRING:
         buffer.append("<string: \"").append(field).append("\">");
         break;
@@ -393,7 +304,7 @@
         break;
 
       case CUSTOM:
-        buffer.append("<custom:\"").append(field).append("\": ").append(factory).append('>');
+        buffer.append("<custom:\"").append(field).append("\": ").append(comparatorSource).append('>');
         break;
 
       default:
@@ -409,7 +320,7 @@
   }
 
   /** Returns true if <code>o</code> is equal to this.  If a
-   *  {@link SortComparatorSource} (deprecated) or {@link
+   *  {@link FieldComparatorSource} or {@link
    *  FieldCache.Parser} was provided, it must properly
    *  implement equals (unless a singleton is always used). */
   public boolean equals(Object o) {
@@ -421,14 +332,13 @@
       && other.type == this.type
       && other.reverse == this.reverse
       && (other.locale == null ? this.locale == null : other.locale.equals(this.locale))
-      && (other.factory == null ? this.factory == null : other.factory.equals(this.factory))
       && (other.comparatorSource == null ? this.comparatorSource == null : other.comparatorSource.equals(this.comparatorSource))
       && (other.parser == null ? this.parser == null : other.parser.equals(this.parser))
     );
   }
 
   /** Returns true if <code>o</code> is equal to this.  If a
-   *  {@link SortComparatorSource} (deprecated) or {@link
+   *  {@link FieldComparatorSource} or {@link
    *  FieldCache.Parser} was provided, it must properly
    *  implement hashCode (unless a singleton is always
    *  used). */
@@ -436,7 +346,6 @@
     int hash=type^0x346565dd + Boolean.valueOf(reverse).hashCode()^0xaf5998bb;
     if (field != null) hash += field.hashCode()^0xff5685dd;
     if (locale != null) hash += locale.hashCode()^0x08150815;
-    if (factory != null) hash += factory.hashCode()^0x34987555;
     if (comparatorSource != null) hash += comparatorSource.hashCode();
     if (parser != null) hash += parser.hashCode()^0x3aaf56ff;
     return hash;
@@ -491,7 +400,7 @@
       return new FieldComparator.ShortComparator(numHits, field, parser);
 
     case SortField.CUSTOM:
-      assert factory == null && comparatorSource != null;
+      assert comparatorSource != null;
       return comparatorSource.newComparator(field, numHits, sortPos, reverse);
 
     case SortField.STRING:
@@ -504,45 +413,4 @@
       throw new IllegalStateException("Illegal sort type: " + type);
     }
   }
-  
-  /**
-   * Attempts to detect the given field type for an IndexReader.
-   * @deprecated
-   */
-  static int detectFieldType(IndexReader reader, String fieldKey) throws IOException {
-    String field = StringHelper.intern(fieldKey);
-    TermEnum enumerator = reader.terms(new Term(field));
-    try {
-      Term term = enumerator.term();
-      if (term == null) {
-        throw new RuntimeException("no terms in field " + field + " - cannot determine sort type");
-      }
-      int ret = 0;
-      if (term.field() == field) {
-        String termtext = term.text().trim();
-
-        try {
-          Integer.parseInt (termtext);
-          ret = SortField.INT;
-        } catch (NumberFormatException nfe1) {
-          try {
-            Long.parseLong(termtext);
-            ret = SortField.LONG;
-          } catch (NumberFormatException nfe2) {
-            try {
-              Float.parseFloat (termtext);
-              ret = SortField.FLOAT;
-            } catch (NumberFormatException nfe3) {
-              ret = SortField.STRING;
-            }
-          }
-        }         
-      } else {
-        throw new RuntimeException("field \"" + field + "\" does not appear to be indexed");
-      }
-      return ret;
-    } finally {
-      enumerator.close();
-    }
-  }
 }

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestCustomSearcherSort.java Tue Oct 13 11:18:25 2009
@@ -104,10 +104,10 @@
 	public void testFieldSortCustomSearcher() throws Exception {
 	  // log("Run testFieldSortCustomSearcher");
 		// define the sort criteria
-	    Sort custSort = new Sort(new SortField[] {
-	            new SortField("publicationDate_"), 
+	    Sort custSort = new Sort(
+	            new SortField("publicationDate_", SortField.STRING), 
 	            SortField.FIELD_SCORE
-	    });
+	    );
 	    Searcher searcher = new CustomSearcher (index, 2);
 	    // search and check hits
 		matchHits(searcher, custSort);
@@ -118,10 +118,10 @@
 	public void testFieldSortSingleSearcher() throws Exception {
 	  // log("Run testFieldSortSingleSearcher");
 		// define the sort criteria
-	    Sort custSort = new Sort(new SortField[] {
-	            new SortField("publicationDate_"), 
+	    Sort custSort = new Sort(
+	            new SortField("publicationDate_", SortField.STRING), 
 	            SortField.FIELD_SCORE
-	    });
+	    );
 	    Searcher searcher = new MultiSearcher(new Searcher[] { new CustomSearcher(
         index, 2) });
 	    // search and check hits
@@ -133,10 +133,10 @@
 	public void testFieldSortMultiCustomSearcher() throws Exception {
 	  // log("Run testFieldSortMultiCustomSearcher");
 		// define the sort criteria
-	    Sort custSort = new Sort(new SortField[] {
-	            new SortField("publicationDate_"), 
+	    Sort custSort = new Sort(
+	            new SortField("publicationDate_", SortField.STRING), 
 	            SortField.FIELD_SCORE
-	    });
+	    );
 	    Searcher searcher = 
 	        new MultiSearcher(new Searchable[] {
 	                new CustomSearcher (index, 0),

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestDateSort.java Tue Oct 13 11:18:25 2009
@@ -72,9 +72,7 @@
   public void testReverseDateSort() throws Exception {
     IndexSearcher searcher = new IndexSearcher(directory, true);
 
-    // Create a Sort object.  reverse is set to true.
-    // problem occurs only with SortField.AUTO:
-    Sort sort = new Sort(new SortField(DATE_TIME_FIELD, SortField.AUTO, true));
+    Sort sort = new Sort(new SortField(DATE_TIME_FIELD, SortField.STRING, true));
 
     QueryParser queryParser = new QueryParser(TEXT_FIELD, new WhitespaceAnalyzer());
     Query query = queryParser.parse("Document");

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestElevationComparator.java Tue Oct 13 11:18:25 2009
@@ -66,10 +66,10 @@
     newq.add(query, BooleanClause.Occur.SHOULD);
     newq.add(getElevatedQuery(new String[] {"id", "a", "id", "x"}), BooleanClause.Occur.SHOULD);
 
-    Sort sort = new Sort(new SortField[]{
+    Sort sort = new Sort(
         new SortField("id", new ElevationComparatorSource(priority), false),
         new SortField(null, SortField.SCORE, reversed)
-      });
+      );
 
     TopDocsCollector topCollector = TopFieldCollector.create(sort, 50, false, true, true, true);
     searcher.search(newq, null, topCollector);

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestFilteredQuery.java Tue Oct 13 11:18:25 2009
@@ -105,7 +105,7 @@
     assertEquals (1, hits[0].doc);
     QueryUtils.check(filteredquery,searcher);
 
-    hits = searcher.search (filteredquery, null, 1000, new Sort("sorter")).scoreDocs;
+    hits = searcher.search (filteredquery, null, 1000, new Sort(new SortField("sorter", SortField.STRING))).scoreDocs;
     assertEquals (1, hits.length);
     assertEquals (1, hits[0].doc);
 

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestSort.java Tue Oct 13 11:18:25 2009
@@ -233,31 +233,31 @@
 
   // test sorts where the type of field is specified
   public void testTypedSort() throws Exception {
-    sort.setSort (new SortField[] { new SortField ("int", SortField.INT), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("int", SortField.INT), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "IGAEC");
     assertMatches (full, queryY, sort, "DHFJB");
 
-    sort.setSort (new SortField[] { new SortField ("float", SortField.FLOAT), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("float", SortField.FLOAT), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "GCIEA");
     assertMatches (full, queryY, sort, "DHJFB");
 
-    sort.setSort (new SortField[] { new SortField ("long", SortField.LONG), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("long", SortField.LONG), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "EACGI");
     assertMatches (full, queryY, sort, "FBJHD");
 
-    sort.setSort (new SortField[] { new SortField ("double", SortField.DOUBLE), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("double", SortField.DOUBLE), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "AGICE");
     assertMatches (full, queryY, sort, "DJHBF");
 
-    sort.setSort (new SortField[] { new SortField ("byte", SortField.BYTE), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("byte", SortField.BYTE), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "CIGAE");
     assertMatches (full, queryY, sort, "DHFBJ");
 
-    sort.setSort (new SortField[] { new SortField ("short", SortField.SHORT), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("short", SortField.SHORT), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "IAGCE");
     assertMatches (full, queryY, sort, "DFHBJ");
 
-    sort.setSort (new SortField[] { new SortField ("string", SortField.STRING), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("string", SortField.STRING), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "AIGEC");
     assertMatches (full, queryY, sort, "DJHFB");
   }
@@ -269,10 +269,10 @@
     r = newRandom();
     ScoreDoc[] result = null;
     IndexSearcher searcher = getFullStrings();
-    sort.setSort(new SortField[] {
+    sort.setSort(
         new SortField("string", SortField.STRING),
         new SortField("string2", SortField.STRING, true),
-        SortField.FIELD_DOC });
+        SortField.FIELD_DOC );
 
     result = searcher.search(new MatchAllDocsQuery(), null, 500, sort).scoreDocs;
 
@@ -331,56 +331,56 @@
     FieldCache fc = FieldCache.DEFAULT;
 
 
-    sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.IntParser(){
+    sort.setSort (new SortField ("parser", new FieldCache.IntParser(){
       public final int parseInt(final String val) {
         return (val.charAt(0)-'A') * 123456;
       }
-    }), SortField.FIELD_DOC });
+    }), SortField.FIELD_DOC );
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
     assertSaneFieldCaches(getName() + " IntParser");
     fc.purgeAllCaches();
 
-    sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.FloatParser(){
+    sort.setSort (new SortField ("parser", new FieldCache.FloatParser(){
       public final float parseFloat(final String val) {
         return (float) Math.sqrt( val.charAt(0) );
       }
-    }), SortField.FIELD_DOC });
+    }), SortField.FIELD_DOC );
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
     assertSaneFieldCaches(getName() + " FloatParser");
     fc.purgeAllCaches();
 
-    sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.LongParser(){
+    sort.setSort (new SortField ("parser", new FieldCache.LongParser(){
       public final long parseLong(final String val) {
         return (val.charAt(0)-'A') * 1234567890L;
       }
-    }), SortField.FIELD_DOC });
+    }), SortField.FIELD_DOC );
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
     assertSaneFieldCaches(getName() + " LongParser");
     fc.purgeAllCaches();
 
-    sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.DoubleParser(){
+    sort.setSort (new SortField ("parser", new FieldCache.DoubleParser(){
       public final double parseDouble(final String val) {
         return Math.pow( val.charAt(0), (val.charAt(0)-'A') );
       }
-    }), SortField.FIELD_DOC });
+    }), SortField.FIELD_DOC );
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
     assertSaneFieldCaches(getName() + " DoubleParser");
     fc.purgeAllCaches();
 
-    sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.ByteParser(){
+    sort.setSort (new SortField ("parser", new FieldCache.ByteParser(){
       public final byte parseByte(final String val) {
         return (byte) (val.charAt(0)-'A');
       }
-    }), SortField.FIELD_DOC });
+    }), SortField.FIELD_DOC );
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
     assertSaneFieldCaches(getName() + " ByteParser");
     fc.purgeAllCaches();
 
-    sort.setSort (new SortField[] { new SortField ("parser", new FieldCache.ShortParser(){
+    sort.setSort (new SortField ("parser", new FieldCache.ShortParser(){
       public final short parseShort(final String val) {
         return (short) (val.charAt(0)-'A');
       }
-    }), SortField.FIELD_DOC });
+    }), SortField.FIELD_DOC );
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
     assertSaneFieldCaches(getName() + " ShortParser");
     fc.purgeAllCaches();
@@ -396,13 +396,13 @@
     sort.setSort(SortField.FIELD_DOC);
     assertMatches (empty, queryX, sort, "");
 
-    sort.setSort (new SortField[] { new SortField ("int", SortField.INT), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("int", SortField.INT), SortField.FIELD_DOC );
     assertMatches (empty, queryX, sort, "");
 
-    sort.setSort (new SortField[] { new SortField ("string", SortField.STRING, true), SortField.FIELD_DOC });
+    sort.setSort (new SortField ("string", SortField.STRING, true), SortField.FIELD_DOC );
     assertMatches (empty, queryX, sort, "");
 
-    sort.setSort (new SortField[] { new SortField ("float", SortField.FLOAT), new SortField ("string", SortField.STRING) });
+    sort.setSort (new SortField ("float", SortField.FLOAT), new SortField ("string", SortField.STRING) );
     assertMatches (empty, queryX, sort, "");
   }
 
@@ -452,28 +452,13 @@
 
   // Test sorting w/ custom FieldComparator
   public void testNewCustomFieldParserSort() throws Exception {
-    sort.setSort (new SortField[] { new SortField ("parser", new MyFieldComparatorSource())});
+    sort.setSort (new SortField ("parser", new MyFieldComparatorSource()));
     assertMatches (full, queryA, sort, "JIHGFEDCBA");
   }
 
-  // test sorts where the type of field is determined dynamically
-  public void testAutoSort() throws Exception {
-    sort.setSort("int");
-    assertMatches (full, queryX, sort, "IGAEC");
-    assertMatches (full, queryY, sort, "DHFJB");
-
-    sort.setSort("float");
-    assertMatches (full, queryX, sort, "GCIEA");
-    assertMatches (full, queryY, sort, "DHJFB");
-
-    sort.setSort("string");
-    assertMatches (full, queryX, sort, "AIGEC");
-    assertMatches (full, queryY, sort, "DJHFB");
-  }
-
   // test sorts in reverse
   public void testReverseSort() throws Exception {
-    sort.setSort (new SortField[] { new SortField (null, SortField.SCORE, true), SortField.FIELD_DOC });
+    sort.setSort (new SortField (null, SortField.SCORE, true), SortField.FIELD_DOC );
     assertMatches (full, queryX, sort, "IEGCA");
     assertMatches (full, queryY, sort, "JFHDB");
 
@@ -481,25 +466,25 @@
     assertMatches (full, queryX, sort, "IGECA");
     assertMatches (full, queryY, sort, "JHFDB");
 
-    sort.setSort ("int", true);
+    sort.setSort (new SortField ("int", SortField.INT, true) );
     assertMatches (full, queryX, sort, "CAEGI");
     assertMatches (full, queryY, sort, "BJFHD");
 
-    sort.setSort ("float", true);
+    sort.setSort (new SortField ("float", SortField.FLOAT, true) );
     assertMatches (full, queryX, sort, "AECIG");
     assertMatches (full, queryY, sort, "BFJHD");
 
-    sort.setSort ("string", true);
+    sort.setSort (new SortField ("string", SortField.STRING, true) );
     assertMatches (full, queryX, sort, "CEGIA");
     assertMatches (full, queryY, sort, "BFHJD");
   }
 
   // test sorting when the sort field is empty (undefined) for some of the documents
   public void testEmptyFieldSort() throws Exception {
-    sort.setSort ("string");
+    sort.setSort (new SortField ("string", SortField.STRING) );
     assertMatches (full, queryF, sort, "ZJI");
 
-    sort.setSort ("string", true);
+    sort.setSort (new SortField ("string", SortField.STRING, true) );
     assertMatches (full, queryF, sort, "IJZ");
     
     sort.setSort (new SortField ("i18n", Locale.ENGLISH));
@@ -508,84 +493,84 @@
     sort.setSort (new SortField ("i18n", Locale.ENGLISH, true));
     assertMatches (full, queryF, sort, "IJZ");
 
-    sort.setSort ("int");
+    sort.setSort (new SortField ("int", SortField.INT) );
     assertMatches (full, queryF, sort, "IZJ");
 
-    sort.setSort ("int", true);
+    sort.setSort (new SortField ("int", SortField.INT, true) );
     assertMatches (full, queryF, sort, "JZI");
 
-    sort.setSort ("float");
+    sort.setSort (new SortField ("float", SortField.FLOAT) );
     assertMatches (full, queryF, sort, "ZJI");
 
     // using a nonexisting field as first sort key shouldn't make a difference:
-    sort.setSort (new SortField[] { new SortField ("nosuchfield", SortField.STRING),
-        new SortField ("float") });
+    sort.setSort (new SortField ("nosuchfield", SortField.STRING),
+        new SortField ("float", SortField.FLOAT) );
     assertMatches (full, queryF, sort, "ZJI");
 
-    sort.setSort ("float", true);
+    sort.setSort (new SortField ("float", SortField.FLOAT, true) );
     assertMatches (full, queryF, sort, "IJZ");
 
     // When a field is null for both documents, the next SortField should be used.
                 // Works for
-    sort.setSort (new SortField[] { new SortField ("int"),
+    sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
-        new SortField ("float") });
+        new SortField ("float", SortField.FLOAT) );
     assertMatches (full, queryG, sort, "ZWXY");
 
     // Reverse the last criterium to make sure the test didn't pass by chance
-    sort.setSort (new SortField[] { new SortField ("int"),
+    sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
-        new SortField ("float", true) });
+        new SortField ("float", SortField.FLOAT, true) );
     assertMatches (full, queryG, sort, "ZYXW");
 
     // Do the same for a MultiSearcher
     Searcher multiSearcher=new MultiSearcher (new Searchable[] { full });
 
-    sort.setSort (new SortField[] { new SortField ("int"),
+    sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
-        new SortField ("float") });
+        new SortField ("float", SortField.FLOAT) );
     assertMatches (multiSearcher, queryG, sort, "ZWXY");
 
-    sort.setSort (new SortField[] { new SortField ("int"),
+    sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
-        new SortField ("float", true) });
+        new SortField ("float", SortField.FLOAT, true) );
     assertMatches (multiSearcher, queryG, sort, "ZYXW");
     // Don't close the multiSearcher. it would close the full searcher too!
 
     // Do the same for a ParallelMultiSearcher
                 Searcher parallelSearcher=new ParallelMultiSearcher (new Searchable[] { full });
 
-    sort.setSort (new SortField[] { new SortField ("int"),
+    sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
-        new SortField ("float") });
+        new SortField ("float", SortField.FLOAT) );
     assertMatches (parallelSearcher, queryG, sort, "ZWXY");
 
-    sort.setSort (new SortField[] { new SortField ("int"),
+    sort.setSort (new SortField ("int", SortField.INT),
                                 new SortField ("string", SortField.STRING),
-        new SortField ("float", true) });
+        new SortField ("float", SortField.FLOAT, true) );
     assertMatches (parallelSearcher, queryG, sort, "ZYXW");
     // Don't close the parallelSearcher. it would close the full searcher too!
   }
 
   // test sorts using a series of fields
   public void testSortCombos() throws Exception {
-    sort.setSort (new String[] {"int","float"});
+    sort.setSort (new SortField ("int", SortField.INT), new SortField ("float", SortField.FLOAT) );
     assertMatches (full, queryX, sort, "IGEAC");
 
-    sort.setSort (new SortField[] { new SortField ("int", true), new SortField (null, SortField.DOC, true) });
+    sort.setSort (new SortField ("int", SortField.INT, true), new SortField (null, SortField.DOC, true) );
     assertMatches (full, queryX, sort, "CEAGI");
 
-    sort.setSort (new String[] {"float","string"});
+    sort.setSort (new SortField ("float", SortField.FLOAT), new SortField ("string", SortField.STRING) );
     assertMatches (full, queryX, sort, "GICEA");
   }
 
   // test using a Locale for sorting strings
   public void testLocaleSort() throws Exception {
-    sort.setSort (new SortField[] { new SortField ("string", Locale.US) });
+    sort.setSort (new SortField ("string", Locale.US) );
     assertMatches (full, queryX, sort, "AIGEC");
     assertMatches (full, queryY, sort, "DJHFB");
 
-    sort.setSort (new SortField[] { new SortField ("string", Locale.US, true) });
+    sort.setSort (new SortField ("string", Locale.US, true) );
     assertMatches (full, queryX, sort, "CEGIA");
     assertMatches (full, queryY, sort, "BFHJD");
   }
@@ -667,7 +652,7 @@
     assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
-    sort.setSort ("int");
+    sort.setSort (new SortField("int", SortField.INT));
     assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
     assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
@@ -675,7 +660,7 @@
     assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
-    sort.setSort ("float");
+    sort.setSort (new SortField("float", SortField.FLOAT));
     assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
     assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
@@ -683,7 +668,7 @@
     assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
-    sort.setSort ("string");
+    sort.setSort (new SortField("string", SortField.STRING));
     assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
     assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
@@ -691,7 +676,7 @@
     assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
-    sort.setSort (new String[] {"int","float"});
+    sort.setSort (new SortField("int", SortField.INT),new SortField("float", SortField.FLOAT));
     assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
     assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
@@ -699,7 +684,7 @@
     assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
-    sort.setSort (new SortField[] { new SortField ("int", true), new SortField (null, SortField.DOC, true) });
+    sort.setSort (new SortField ("int", SortField.INT, true), new SortField (null, SortField.DOC, true) );
     assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
     assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
@@ -707,7 +692,7 @@
     assertSameValues (scoresA, getScores (full.search (queryA, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresA, getScores (multi.search (queryA, null, 1000, sort).scoreDocs, multi));
 
-    sort.setSort (new String[] {"float","string"});
+    sort.setSort (new SortField("int", SortField.INT),new SortField("string", SortField.STRING));
     assertSameValues (scoresX, getScores (full.search (queryX, null, 1000, sort).scoreDocs, full));
     assertSameValues (scoresX, getScores (multi.search (queryX, null, 1000, sort).scoreDocs, multi));
     assertSameValues (scoresY, getScores (full.search (queryY, null, 1000, sort).scoreDocs, full));
@@ -909,52 +894,52 @@
     expected = isFull ? "IDHFGJABEC" : "IDHFGJAEBC";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort(new SortField[] {new SortField ("int", SortField.INT), SortField.FIELD_DOC});
+    sort.setSort(new SortField ("int", SortField.INT), SortField.FIELD_DOC);
     expected = isFull ? "IDHFGJABEC" : "IDHFGJAEBC";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort("int");
+    sort.setSort(new SortField("int", SortField.INT));
     expected = isFull ? "IDHFGJABEC" : "IDHFGJAEBC";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort(new SortField[] {new SortField ("float", SortField.FLOAT), SortField.FIELD_DOC});
+    sort.setSort(new SortField ("float", SortField.FLOAT), SortField.FIELD_DOC);
     assertMatches(multi, queryA, sort, "GDHJCIEFAB");
 
-    sort.setSort("float");
+    sort.setSort(new SortField("float", SortField.FLOAT));
     assertMatches(multi, queryA, sort, "GDHJCIEFAB");
 
-    sort.setSort("string");
+    sort.setSort(new SortField("string", SortField.STRING));
     assertMatches(multi, queryA, sort, "DJAIHGFEBC");
 
-    sort.setSort("int", true);
+    sort.setSort(new SortField("int", SortField.INT, true));
     expected = isFull ? "CABEJGFHDI" : "CAEBJGFHDI";
     assertMatches(multi, queryA, sort, expected);
 
-    sort.setSort("float", true);
+    sort.setSort(new SortField("float", SortField.FLOAT, true));
     assertMatches(multi, queryA, sort, "BAFECIJHDG");
 
-    sort.setSort("string", true);
+    sort.setSort(new SortField("string", SortField.STRING, true));
     assertMatches(multi, queryA, sort, "CBEFGHIAJD");
 
-    sort.setSort(new String[] {"int","float"});
+    sort.setSort(new SortField("int", SortField.INT),new SortField("float", SortField.FLOAT));
     assertMatches(multi, queryA, sort, "IDHFGJEABC");
 
-    sort.setSort(new String[] {"float","string"});
+    sort.setSort(new SortField("float", SortField.FLOAT),new SortField("string", SortField.STRING));
     assertMatches(multi, queryA, sort, "GDHJICEFAB");
 
-    sort.setSort("int");
+    sort.setSort(new SortField ("int", SortField.INT));
     assertMatches(multi, queryF, sort, "IZJ");
 
-    sort.setSort("int", true);
+    sort.setSort(new SortField ("int", SortField.INT, true));
     assertMatches(multi, queryF, sort, "JZI");
 
-    sort.setSort("float");
+    sort.setSort(new SortField ("float", SortField.FLOAT));
     assertMatches(multi, queryF, sort, "ZJI");
 
-    sort.setSort("string");
+    sort.setSort(new SortField ("string", SortField.STRING));
     assertMatches(multi, queryF, sort, "ZJI");
 
-    sort.setSort("string", true);
+    sort.setSort(new SortField ("string", SortField.STRING, true));
     assertMatches(multi, queryF, sort, "IJZ");
 
     // up to this point, all of the searches should have "sane" 
@@ -963,13 +948,13 @@
     // next we'll check Locale based (String[]) for 'string', so purge first
     FieldCache.DEFAULT.purgeAllCaches();
 
-    sort.setSort(new SortField[] { new SortField ("string", Locale.US) });
+    sort.setSort(new SortField ("string", Locale.US) );
     assertMatches(multi, queryA, sort, "DJAIHGFEBC");
 
-    sort.setSort(new SortField[] { new SortField ("string", Locale.US, true) });
+    sort.setSort(new SortField ("string", Locale.US, true) );
     assertMatches(multi, queryA, sort, "CBEFGHIAJD");
 
-    sort.setSort(new SortField[] { new SortField ("string", Locale.UK) });
+    sort.setSort(new SortField ("string", Locale.UK) );
     assertMatches(multi, queryA, sort, "DJAIHGFEBC");
 
     assertSaneFieldCaches(getName() + " Locale.US + Locale.UK");

Modified: lucene/java/trunk/src/test/org/apache/lucene/search/TestStressSort.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/search/TestStressSort.java?rev=824697&r1=824696&r2=824697&view=diff
==============================================================================
--- lucene/java/trunk/src/test/org/apache/lucene/search/TestStressSort.java (original)
+++ lucene/java/trunk/src/test/org/apache/lucene/search/TestStressSort.java Tue Oct 13 11:18:25 2009
@@ -207,46 +207,34 @@
       boolean reverse = 1 == r;
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("byte", SortField.BYTE, reverse)});
+      sort.setSort(new SortField("byte", SortField.BYTE, reverse));
       
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("short", SortField.SHORT, reverse)});
+      sort.setSort(new SortField("short", SortField.SHORT, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("int", SortField.INT, reverse)});
+      sort.setSort(new SortField("int", SortField.INT, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("long", SortField.LONG, reverse)});
+      sort.setSort(new SortField("long", SortField.LONG, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("float", SortField.FLOAT, reverse)});
+      sort.setSort(new SortField("float", SortField.FLOAT, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("double", SortField.DOUBLE, reverse)});
+      sort.setSort(new SortField("double", SortField.DOUBLE, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("string", SortField.STRING_VAL, reverse)});
+      sort.setSort(new SortField("string", SortField.STRING_VAL, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField("stringIdx", SortField.STRING, reverse)});
-
-      //sorts[sortCount++] = sort = new Sort();
-      //sort.setSort(new SortField[] {new SortField("string", SortField.STRING_ORD, reverse)});
-
-      //sorts[sortCount++] = sort = new Sort();
-      //sort.setSort(new SortField[] {new SortField("string", SortField.STRING_ORD_VAL, reverse)});
-
-      //sorts[sortCount++] = sort = new Sort();
-      //sort.setSort(new SortField[] {new SortField("string", SortField.STRING_ORD_VAL_DEM, reverse)});
-
-      //sorts[sortCount++] = sort = new Sort();
-      //sort.setSort(new SortField[] {new SortField("string", SortField.STRING_ORD_VAL_DEM2, reverse)});
+      sort.setSort(new SortField("stringIdx", SortField.STRING, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField(null, SortField.SCORE, reverse)});
+      sort.setSort(new SortField(null, SortField.SCORE, reverse));
 
       sorts[sortCount++] = sort = new Sort();
-      sort.setSort(new SortField[] {new SortField(null, SortField.DOC, reverse)});
+      sort.setSort(new SortField(null, SortField.DOC, reverse));
     }
 
     Query[] queries = new Query[4];
@@ -288,30 +276,8 @@
                 // Single field sort
                 sort = sort1;
               } else {
-                sort = new Sort(new SortField[] {sort1.getSort()[0], sorts[s2].getSort()[0]});
-              }
-
-              // Old
-              Sort oldSort = getOldSort(sort);
-
-              if (VERBOSE) {
-                System.out.println("query=" + query);
-                if (sx == 0) {
-                  System.out.println("  single-segment index");
-                } else if (sx == 1) {
-                  System.out.println("  few-segment index");
-                } else {
-                  System.out.println("  many-segment index");
-                }
-                System.out.println("  numHit=" + queueSize);
-                System.out.println("  old=" + oldSort);
-                System.out.println("  new=" + sort);
+                sort = new Sort(sort1.getSort()[0], sorts[s2].getSort()[0]);
               }
-
-              TopDocs newHits = searcher.search(query, null, queueSize, sort);
-              TopDocs oldHits = searcher.search(query, null, queueSize, oldSort);
-
-              compare(oldHits, newHits);
             }
           }
         }
@@ -350,24 +316,6 @@
     close();
   }
 
-  private Sort getOldSort(Sort sort) {
-    SortField[] fields = sort.getSort();
-    SortField[] oldFields = new SortField[fields.length];
-    for(int i=0;i<fields.length;i++) {
-      int sortType;
-      if (fields[i].getField() != null && fields[i].getField().equals("string")) {
-        sortType = SortField.STRING;
-      } else {
-        sortType = fields[i].getType();
-      }
-      oldFields[i] = new SortField(fields[i].getField(),
-                                   sortType,
-                                   fields[i].getReverse());
-      oldFields[i].setUseLegacySearch(true);
-    }
-    return new Sort(oldFields);
-  }
-
   private void compare(TopDocs oldHits, TopDocs newHits) {
     assertEquals(oldHits.totalHits, newHits.totalHits);
     assertEquals(oldHits.scoreDocs.length, newHits.scoreDocs.length);



Mime
View raw message