lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: How to not overwrite a Document if it 'already exists'?
Date Tue, 05 May 2009 12:15:07 GMT
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 <adb@teamware.com> 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: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message