Hi all,
Before posting this question I have read a couple of old threads on this list
on ways to update an existing index. the conclusion was to recreate a new
index. unfortunalty this may not be possible in my case (please correct me if I
am wrong).
let me first describe what I am having trouble with:
I have an index that has all sort of field types
(keyword,Unstored,Text,Unindexed), I need to update the value for a field that
is Unindexed for all the documents in the index. (I can't recreate the index
from scratch since the files I used to create the index are not available
anymore).
so my idea was to do somthing like the following:
1 - create IndexWriter/Indexreader/IndexSearcher for existing index
2 - getAllDocuments(Searcher) as Hits.
3 - for each Hits object
Document origDoc = hits.doc( i );
origDoc.removeField( fieldToBeUpdated ); // this field is Unindexed
origDoc.add( new Field( fieldToBeUpdated
,newValue,Field.Store.YES,Field.Index.NO ) );
reader.deleteDocument( hits.id( i ) );
writer.addDocument( origDoc );
4 - close Reader/Writer/Searcher
5 - optimize index.
is this the right approach?. what will happen to the fields in the index that
are Unstored in the new index? am I going to lose any data?.
Thank you very much for all your help.
Omar.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]