Hi Paul, If you do not store all the data inside lucene you have to get you updated data from you spreadsheet again. Even if you would store all the data you would have to update the document by creating a new one and adding it to the index using updateDocument(). You can not update just one single field. If you get a Document from your index calling removeField() does not have any effect. The add and removeField methodes only make sense prior to adding a document to an index. These methods cannot be used to change the content of an existing index! In order to achieve this, a document has to be deleted from an index and a new changed version of that document has to be added.
Creating and updating your document from the spreadsheet data is the way to go. simon On Tue, Mar 17, 2009 at 5:28 PM, Paul Taylor <paul_t...@fastmail.fm> wrote: > I am using lucene to index rows in a spreadsheet , each row is a Document, > and the document indexes 10 fields from the row plus the row number used to > relate thethe Document to the row number > So when someone modifies one of the 10 fields I am interested in a row I > have to update the document with the new data > > writer = new IndexWriter(directory, analyzer); > Document document = createDocument(row); > writer.updateDocument(new Term(ROW_NUMBER, "" + row), document); > writer.optimize(); > writer.close(); > > Because I can't retrieve the existing Document for a row from a writer I > recreate the document when one of the values has changed, but this means I > have to go off and get all the values again even though I am only changing > one. is there a better way to do this, I thought > that I could retrive the document using an IndexReader and then modify it > using removeField(),AddField() but there is extra overhead in doing in > having to create a reader to get the document - so which would be best. > > thanks Paul > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org > For additional commands, e-mail: java-user-h...@lucene.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org