lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "JMA" <>
Subject Adding fields to an existing index fails?
Date Fri, 14 Jul 2006 08:09:24 GMT

I have an existing index.  I want to add new fields to each document in the index.  
Ideally I would do it in-place on the same index, but let's assume I can create a new, separate
Easy I thought:

IndexReader reader =;
int maxdocs = reader.maxDoc();

IndexWriter  writer = new IndexWriter("indexWithMoreFields", new StandardAnalyzer(), true);

for (int i=0; i<maxdocs; i++) {
   Document d = reader.document(i);
   Field f = new Field("extraField", text_for_extra_field, true, true, true);

- This is not working two ways:
1) Not all documents in the original index appear be copied
2) Some of the fields from the original index are dropped when copying the document

Now I figure it has something to do with the original index not "storing" all the original
fields (indexed, tokenized, not stored) and perhaps this is not the proper way to loop through
an index, so I can understand that my approach is incorrect.  However, this seems like something
that would be very common.  I do not want to reindex every document from scratch again just
to add a field.

Help please.


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

View raw message