lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Townsend" <david.towns...@magus.co.uk>
Subject hits.length() changes during delete process.
Date Fri, 03 Dec 2004 16:05:10 GMT
I have a delete script

IndexSearcher searcher = new IndexSearcher(reader);

Hits hits = searcher.search(query);
log.info("there are " + hits.length() + " hits");

for (int i = 0; i < hits.length(); i++) {
  log.info(hits.length() + " " + i + " " + hits.id(i));
  reader.delete(hits.id(i));
}

which iterates through the results of a search and deletes the returns.  I keep getting an
ArrayIndexOutOfBoundsException.  I've found the reason is that hits.length() actually changes
during the iteration in large regular steps i.e 

The hits length is initially 10003

after 100 deletions hits.length() changes to  9903
after 200 deletions hits.length() changes to 9803

then changes after 
200 deletions
400
800
1600
3200

So the short question is, should the hits object be changing and what is the best way to delete
all the results of a search (it's a range query so I can't use delete(Term term)? 

cheers.

David

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


Mime
View raw message