lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 21189] - Hits.length() returns to large value
Date Mon, 30 Jun 2003 15:35:32 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21189>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21189

Hits.length() returns to large value





------- Additional Comments From luetzken@itaw.hu-berlin.de  2003-06-30 15:35 -------
Ok, I made some further tests, it's not the length() method; but I don't realize 
the problem.

Here is some code that reproduces the behavior I have described. A strange 
observation is, that the ArrayIndexOutOfBoundsException is thrown for tests with 
document counts larger than 100.

public class Test {

   public static void main(String[] args) 
      throws IOException
   {
      File dir = new File( 
         System.getProperty("java.io.tmpdir") + File.separator + "index");
      dir.mkdirs();
      
      
      IndexWriter writer = new IndexWriter(dir,
            new SimpleAnalyzer(),
            true);
                         
      for(int i = 0; i < 101; i++) {
         Document doc = new Document();
         doc.add(Field.Keyword("f", "v"));
         writer.addDocument(doc);
      }
      
      writer.close();
      
      Query q = new TermQuery(new Term("f", "v"));
      
      IndexReader reader = IndexReader.open(dir);
      IndexSearcher searcher = new IndexSearcher(reader);
      Hits hits = searcher.search(q);
      
      for(int i = 0; i < hits.length(); i++) {
         reader.delete(hits.id(i)); 
      }
      reader.close();
   }
}

throws 
java.lang.ArrayIndexOutOfBoundsException: 100 >= 100
	at java.util.Vector.elementAt(Vector.java:427)
	at org.apache.lucene.search.Hits.hitDoc(Hits.java:147)
	at org.apache.lucene.search.Hits.id(Hits.java:137)
	at tests.Test.main(LuceneTC.java:50)

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


Mime
View raw message