lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Morus Walter <morus.wal...@tanto.de>
Subject Re: Updating Index.
Date Fri, 08 Apr 2005 06:52:07 GMT
pashupathinath writes:
>    how can i traverse through the values stored in the
> index and make sure that the new records are not
> duplicated ? once i encounter the duplicate primary
> key, i should be able to delete all the various fields
> values associated with that primary key.
>    
There's no way to delete fields of a document in lucene. You can only 
delete documents. So update means to delete the old document for a 
given record and add the new record.

Deletion can be done based on the pk? Lucene will do the index search 
for you:
http://lucene.apache.org/java/docs/api/org/apache/lucene/index/IndexReader.html#delete(org.apache.lucene.index.Term)

The hard part is that you cannot have an index reader doing deletions
and an index writer doing document adds at the same time.
So you have to delete first and add then.

You can access all documents having a certain term using 
http://lucene.apache.org/java/docs/api/org/apache/lucene/index/IndexReader.html#termDocs(org.apache.lucene.index.Term)
if you really want to do that yourself...

HTH
	Morus

---------------------------------------------------------------------
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