Lucene doesn't provide any way to do this, except opening a reader.

Opening a reader is not "that" expensive if you use it for this
purpose.  EG neither norms nor FieldCache will be loaded if you just
enumerate the term docs.

But, you can let Lucene do the same thing for you by just always using
updateDocument, which'll remove the old doc if it's present.

Mike

On Tue, May 5, 2009 at 6:45 AM, Antony Bowesman <[email protected]> wrote:
> I'm adding Documents in batches to an index with IndexWriter.  In certain
> circumstances, I do not want to add the Document if it already exists, where
> existence is determined by field id=myId.
>
> Is there any way to do this with IndexWriter or do I have to open a reader
> and look for the term id:XXX?  Given that opening a reader is expensive, is
> there any way to do this efficiently?
>
> I guess what I want is
>
> IndexWriter.addDocumentIfMissing(Term term, Document doc, Analyzer analyzer)
>
> Thanks
> Antony
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to