lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miles Barr <>
Subject Re: Combining Documents
Date Wed, 02 Feb 2005 10:20:51 GMT
On Tue, 2005-02-01 at 17:28 -0500, Luke Shannon wrote:
> I have a situation where I need to combine the fields returned from one
> document to an existing document.
> Is there something in the API for this that I'm missing or is this the best
> way:
> //add the fields contained in the PDF document to the existing doc Document
> Document attachedDoc = LucenePDFDocument.getDocument(attached);
>             Enumeration docFields = attachedDoc.fields();
>              while (docFields.hasMoreElements()) {
>                      doc.add((Field)docFields.nextElement());
>               }

If you're adding fields to an existing document you need to ensure that
all the existing fields are stored. 

Basically what you need to do is:

1. Retrieve the existing document
2. Remove it from the index
3. Add the new fields
4. Add it back to the index

If you don't remove it from the index you'll have two copies, one with
the new fields and one without. 

If the fields in the existing document are not stored then when you add
it back to the index they will be lost.

Miles Barr <>
Runtime Collective Ltd.

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

View raw message