Unstored fields are just that - not stored. Their contents cannot be retrieved from the index.
In order to do what you have said, you have a few options:
- make each field stored so that you can make a new document from an existing one
- if your unstored field is large (ie. the contents of a text file), store a pointer to the original contents in the index (ie. its file path). When creating a new document, read this pointer from the existing document, fetch the field contents from the original source (ie. from the text file), and then add it unstored to your new document
- if you are not altering the unstored field, you can retrieve the existing document, update its other fields and then put it back into the index. This might only be possible in later versions of Lucene though (v2.2 upwards). EDIT: having tried this option, it does not work - see my comment below.
Ultimately, if you need to get the value of the unstored field, you will have to make it stored.
adrianbanks
2009-08-22 15:39:34