List Info

Thread: Adding fields to an existing index fails?




Adding fields to an existing index fails?
user name
2006-07-14 08:48:15
On Fri, 2006-07-14 at 04:09 -0400, JMA wrote:
> I have an existing index.  I want to add new fields to
each document in the index.

>    Document d = reader.document(i);
> 						
>    Field f = new Field("extraField",
text_for_extra_field, true, true, true);
>    d.add(f);			
>    writer.addDocument(d);

Your problem is this: Lucene is an index and not a database.
A lot of
semantic information is lost when you pass a document to the
writer. If
you want to add data to an existing document in the index,
you really
want to remove the old and create a new one.

It would be possible to analyze the index and re-create the
information,
but as far as I know, you will not find that functionality
in the API.
Basically you would have to extract the tokens (unless the
data is
stored and you know for a fact what analyzer you used for
each
document), extract boost values, take a look at the vectors,
et.c. It's
quite a messy procedure.


Please try to create a new email rather than replying to and
changing
the subject of an old thread next time. And please post
questions of
this character to the users- rather than the dev-list.


------------------------------------------------------------
---------
To unsubscribe, e-mail: java-dev-unsubscribelucene.apache.org
For additional commands, e-mail: java-dev-helplucene.apache.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )