Hi.
You just have to add a field in your document object before adding it to the
index.
The field should be of "keyword" type. You can use a code of that kind :
IndexWriter writer = new IndexWriter("path_to_your_index",
your_analyzer_object);
Document doc = new Document();
doc.add(Field.keyword("id"), (String)pkey); // add an "id" field
containig the "pkey" value (received from the db for instance)
// you can add other fields here
writer.addDocument(doc).
writer.optimize();
writer.close();
Gilles.
-----Message d'origine-----
De : jt oob [mailto:[EMAIL PROTECTED]
Envoy� : mercredi 19 novembre 2003 15:43
� : Lucene-Users-List
Objet : Document ID's and duplicates
Hi folks,
I've got a feeling the answer to this has either been posted on here
recently, or is on the site somewhere - but i can't find it. Apologies
if i'm going over old ground.
What is the best way force documents to be only indexed once?
Is it a case of having a field with a unique value for the document and
searching the index for that field before adding?
If that is the way to do it, would it be a good idea to add an
additional field type which would take care of this behind the scenes?
Many people move to lucene after discovering the downfalls of text
searching in Databases (like me), and would love a "primary key" type
field.
Regards,
jt
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://mail.messenger.yahoo.co.uk
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]