lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r824692 - in /lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search: TestCustomSearcherSort.java TestDateSort.java TestFilteredQuery.java TestSort.java TestStressSort.java
Date Tue, 13 Oct 2009 11:13:25 GMT
Author: uschindler
Date: Tue Oct 13 11:13:25 2009
New Revision: 824692

URL: http://svn.apache.org/viewvc?rev=824692&view=rev
Log:
LUCENE-1972: remove deprecated method calls to new Sort()/setSort/new SortField() in BW branch

Modified:
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
    lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestStressSort.java

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java?rev=824692&r1=824691&r2=824692&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestCustomSearcherSort.java
Tue Oct 13 11:13:25 2009
@@ -105,7 +105,7 @@
 	  // log("Run testFieldSortCustomSearcher");
 		// define the sort criteria
 	    Sort custSort = new Sort(new SortField[] {
-	            new SortField("publicationDate_"), 
+	            new SortField("publicationDate_", SortField.STRING), 
 	            SortField.FIELD_SCORE
 	    });
 	    Searcher searcher = new CustomSearcher (index, 2);
@@ -119,7 +119,7 @@
 	  // log("Run testFieldSortSingleSearcher");
 		// define the sort criteria
 	    Sort custSort = new Sort(new SortField[] {
-	            new SortField("publicationDate_"), 
+	            new SortField("publicationDate_", SortField.STRING), 
 	            SortField.FIELD_SCORE
 	    });
 	    Searcher searcher = new MultiSearcher(new Searcher[] { new CustomSearcher(
@@ -134,7 +134,7 @@
 	  // log("Run testFieldSortMultiCustomSearcher");
 		// define the sort criteria
 	    Sort custSort = new Sort(new SortField[] {
-	            new SortField("publicationDate_"), 
+	            new SortField("publicationDate_", SortField.STRING), 
 	            SortField.FIELD_SCORE
 	    });
 	    Searcher searcher = 

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java?rev=824692&r1=824691&r2=824692&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestDateSort.java
Tue Oct 13 11:13: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/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java?rev=824692&r1=824691&r2=824692&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestFilteredQuery.java
Tue Oct 13 11:13:25 2009
@@ -106,7 +106,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/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java?rev=824692&r1=824691&r2=824692&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestSort.java
Tue Oct 13 11:13:25 2009
@@ -457,21 +457,6 @@
     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
});
@@ -482,25 +467,25 @@
     assertMatches (full, queryX, sort, "IGECA");
     assertMatches (full, queryY, sort, "JHFDB");
 
-    sort.setSort ("int", true);
+    sort.setSort (new SortField[] { new SortField ("int", SortField.INT, true) });
     assertMatches (full, queryX, sort, "CAEGI");
     assertMatches (full, queryY, sort, "BJFHD");
 
-    sort.setSort ("float", true);
+    sort.setSort (new SortField[] { new SortField ("float", SortField.FLOAT, true) });
     assertMatches (full, queryX, sort, "AECIG");
     assertMatches (full, queryY, sort, "BFJHD");
 
-    sort.setSort ("string", true);
+    sort.setSort (new SortField[] { 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[] { new SortField ("string", SortField.STRING) });
     assertMatches (full, queryF, sort, "ZJI");
 
-    sort.setSort ("string", true);
+    sort.setSort (new SortField[] { new SortField ("string", SortField.STRING, true) });
     assertMatches (full, queryF, sort, "IJZ");
     
     sort.setSort (new SortField ("i18n", Locale.ENGLISH));
@@ -509,74 +494,74 @@
     sort.setSort (new SortField ("i18n", Locale.ENGLISH, true));
     assertMatches (full, queryF, sort, "IJZ");
 
-    sort.setSort ("int");
+    sort.setSort (new SortField[] { new SortField ("int", SortField.INT) });
     assertMatches (full, queryF, sort, "IZJ");
 
-    sort.setSort ("int", true);
+    sort.setSort (new SortField[] { new SortField ("int", SortField.INT, true) });
     assertMatches (full, queryF, sort, "JZI");
 
-    sort.setSort ("float");
+    sort.setSort (new SortField[] { 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") });
+        new SortField ("float", SortField.FLOAT) });
     assertMatches (full, queryF, sort, "ZJI");
 
-    sort.setSort ("float", true);
+    sort.setSort (new SortField[] { 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[] { 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[] { 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[] { 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[] { 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[] { 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[] { 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[] { 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[] { 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[] { new SortField ("float", SortField.FLOAT), new SortField
("string", SortField.STRING) });
     assertMatches (full, queryX, sort, "GICEA");
   }
 
@@ -668,7 +653,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));
@@ -676,7 +661,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));
@@ -684,7 +669,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));
@@ -692,7 +677,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[] {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));
@@ -700,7 +685,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[] { 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));
@@ -708,7 +693,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[] {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));
@@ -914,48 +899,48 @@
     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});
     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[] {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[] {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" 

Modified: lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestStressSort.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestStressSort.java?rev=824692&r1=824691&r2=824692&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestStressSort.java
(original)
+++ lucene/java/branches/lucene_2_9_back_compat_tests/src/test/org/apache/lucene/search/TestStressSort.java
Tue Oct 13 11:13:25 2009
@@ -290,28 +290,6 @@
               } 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);
-              }
-
-              TopDocs newHits = searcher.search(query, null, queueSize, sort);
-              TopDocs oldHits = searcher.search(query, null, queueSize, oldSort);
-
-              compare(oldHits, newHits);
             }
           }
         }
@@ -350,24 +328,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