Thank you all for the responses. I'll try to work around this.
On 9/15/05, Chris Hostetter <[EMAIL PROTECTED]> wrote: > > > : : I wasn't expect addDocument to close it. > : : I am wondering if there is a reason that rdr should be > : : closed after addDocument, and if there is a way to leave it open ? > > : What stops you from using the reader before you add the document to the > : index? > > That doesn't really help people who want to use the same reader for two > different fields (ie: with different analyzers) > > > I've never accutally used a Field based on a Reader, so it's never occured > to me to wonder who is responsible for closeing the reader -- I agree, > it's strange, and not what i would have expected either. > > > Looking at the code, it seems really hairy. I can't see any actual > garuntee that any Reader (including the StringReaders opened under the > cover when you make a Field using a string) will/won't be closed -- if you > use an Analyzer that comes with Lucene, they all seem to use the Tokenizer > class (in one way or another) and *it* is what closes the Reader when it > gets .close()ed -- but there is no reason to believe that any existing of > future third party analyzer will use that class, the API just requires > that they provide a TokenStream (the superclass). TokenStream's .close() > is abstract, so people are free to write Analyzers that don't close the > Reader's they get. > > I can't think of any clean way to change this without causing lots of > backwards compatibility problems for lots of people. > > > : -----Original Message----- > : From: Beady Geraghty [mailto:[EMAIL PROTECTED] > : Sent: Thursday, September 15, 2005 2:30 AM > : To: java-user@lucene.apache.org > : Subject: input reader closed after IndexWriter.addDocument(doc) > : > : am new to Lucene. I don't seem to be able to find the answer to my > : question > : from the archive. I hope to get some help with my problem. > : I have : > : Document doc = new Document(); > : doc.add( Field.Text( "contents", rdr ); > : myIndexWriter.addDocument( doc ); > : After this point, it appears that rdr is closed. > : What happens is that I want to subsequently > : use the rdr again by positioning back to the beginning > : of the file, and since I opened the rdr (input stream), > : Thank you. > : > : > : --------------------------------------------------------------------- > : To unsubscribe, e-mail: [EMAIL PROTECTED] > : For additional commands, e-mail: [EMAIL PROTECTED] > : > > > > -Hoss > >