lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject cvs commit: jakarta-lucene-sandbox/contributions/fulcrum SearchResults.java
Date Sat, 29 Jun 2002 07:59:00 GMT
kelvint     2002/06/29 00:59:00

  Modified:    contributions/fulcrum SearchResults.java
  Log:
  Fixed horrible bug in returning results within a range.
  
  Revision  Changes    Path
  1.4       +17 -6     jakarta-lucene-sandbox/contributions/fulcrum/SearchResults.java
  
  Index: SearchResults.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene-sandbox/contributions/fulcrum/SearchResults.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SearchResults.java	13 May 2002 10:56:54 -0000	1.3
  +++ SearchResults.java	29 Jun 2002 07:58:59 -0000	1.4
  @@ -29,20 +29,30 @@
   
       public SearchResults(Hits hits) throws IOException
       {
  -        this(hits, 0, hits.length());
  +        this(hits, 0, hits.length() - 1);
       }
   
       public SearchResults(Hits hits, int from, int to) throws IOException
       {
  -        hitsDocuments = new Document[hits.length()];
           totalNumberOfResults = hits.length();
           if (to > totalNumberOfResults)
           {
  -            to = totalNumberOfResults;
  +            to = totalNumberOfResults - 1;
           }
  -        for (int i = from; i < to; i++)
  +        int numberOfResults = to - from + 1;
  +        if (numberOfResults > -1)
           {
  -            hitsDocuments[i] = hits.doc(i);
  +            hitsDocuments = new Document[numberOfResults];
  +            for (int i = to, j = 0; i >= from; i--, j++)
  +            {
  +                hitsDocuments[j] = hits.doc(i);
  +            }
  +        }
  +        else
  +        {
  +            throw new IllegalArgumentException("Range of results requested " +
  +                                               "exceed total number of search " +
  +                                               "results returned.");
           }
       }
   
  @@ -52,7 +62,8 @@
       }
   
       /**
  -     * Obtain the results of the search as objects.
  +     * Obtain the results of the search as objects. The objects returned are
  +     * not guaranteed to be unique.
        */
       public Object[] getResultsAsObjects()
       {
  
  
  

--
To unsubscribe, e-mail:   <mailto:lucene-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-dev-help@jakarta.apache.org>


Mime
View raw message