Author: cutting
Date: Thu Jan  5 10:38:44 2006
New Revision: 366242

URL: http://svn.apache.org/viewcvs?rev=366242&view=rev
Log:
Fix NegativeArraySizeException.

Modified:
    lucene/nutch/trunk/conf/nutch-default.xml
    
lucene/nutch/trunk/src/java/org/apache/nutch/searcher/LuceneQueryOptimizer.java

Modified: lucene/nutch/trunk/conf/nutch-default.xml
URL: 
http://svn.apache.org/viewcvs/lucene/nutch/trunk/conf/nutch-default.xml?rev=366242&r1=366241&r2=366242&view=diff
==============================================================================
--- lucene/nutch/trunk/conf/nutch-default.xml (original)
+++ lucene/nutch/trunk/conf/nutch-default.xml Thu Jan  5 10:38:44 2006
@@ -661,10 +661,11 @@
 
 <property>
   <name>searcher.max.hits</name>
-  <value>2147483647</value>
-  <description>Search stops after this many hits are found.  Setting
-  this to smaller values can make searches much faster.  With a sorted
-  index, the quality of the hits suffers little.</description>
+  <value>-1</value>
+  <description>If positive, search stops after this many hits are
+  found.  Setting this to small, positive values (e.g., 1000) can make
+  searches much faster.  With a sorted index, the quality of the hits
+  suffers little.</description>
 </property>
 
 <!-- URL normalizer properties -->

Modified: 
lucene/nutch/trunk/src/java/org/apache/nutch/searcher/LuceneQueryOptimizer.java
URL: 
http://svn.apache.org/viewcvs/lucene/nutch/trunk/src/java/org/apache/nutch/searcher/LuceneQueryOptimizer.java?rev=366242&r1=366241&r2=366242&view=diff
==============================================================================
--- 
lucene/nutch/trunk/src/java/org/apache/nutch/searcher/LuceneQueryOptimizer.java 
(original)
+++ 
lucene/nutch/trunk/src/java/org/apache/nutch/searcher/LuceneQueryOptimizer.java 
Thu Jan  5 10:38:44 2006
@@ -37,8 +37,7 @@
  * which do not affect ranking but might otherwise slow search considerably. */
 class LuceneQueryOptimizer {
 
-  private static int MAX_HITS =
-    NutchConf.get().getInt("searcher.max.hits", Integer.MAX_VALUE);
+  private static int MAX_HITS = NutchConf.get().getInt("searcher.max.hits",-1);
 
   private static class LimitExceeded extends RuntimeException {
     private int maxDoc;
@@ -150,6 +149,13 @@
       }        
     }
     if (sortField == null && !reverse) {
+
+      // no hit limit
+      if (MAX_HITS <= 0) {
+        return searcher.search(query, filter, numHits);
+      }
+
+      // hits limited -- use a LimitedCollector
       LimitedCollector collector = new LimitedCollector(numHits, MAX_HITS);
       LimitExceeded exceeded = null;
       try {


Reply via email to