lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <>
Subject Calling addDocument twice for the same document
Date Fri, 07 Apr 2006 01:03:43 GMT
Hi all.

I have a situation where a Document is constructed with a bunch of 
strings and a couple of readers.  An error may occur while reading from 
the readers, and in these situations, we want to remove the reader and 
then try to index the same document again.

I've made a test case which creates a document containing only strings, 
and calls addDocument twice with that document.  This appears to behave 
as expected, but I'm wondering mainly if I'm making a bad assumption here.

The next step is probably more interesting: removing the readers.  At 
present, Document has no convenient way for us to remove these fields. 
As removeField() and removeFields() take a string, I can't use those 
because we only want to remove fields where there is a reader and no 
string, and these methods remove all fields with the given name.  And as 
fields() returns an Enumeration instead of an Iterator, we can't just 
iterate through and remove the ones we don't want.

What would be the easiest way out of that?  At the moment I'm thinking I 
will implement a fieldIterator() method that returns an Iterator, and 
then the code will loop through and remove() any fields which have a 


Daniel Noll

Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia    Ph: +61 2 9280 0699
Web:                        Fax: +61 2 9212 6902

This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message