Hi,

Can you check the return value of your reader.delete(...); call? According to the Javadocs, it should return the number of documents it deleted, maybe you can verify that it is deleting an entry?

Jeff

Otis Gospodnetic wrote:
The code looks fine.  Unfortunately, the provided code is not a full,
self-sufficient class that I can run on my machine to verify the
behaviour that you are describing.

Otis

--- Robert Koberg <[EMAIL PROTECTED]> wrote:

Hi,

I am using the latest binary distro (lucene-20030620.jar).  I am
trying to
delete an entry from an index and then add it back with updated
information.

The entry is a content XML piece with some metadata added to the
Document. I
try to delete the entry by using a Term derived by the Field 'id' and
the
value of that field. The value is correct. What happens is that two
entries
exist after executing the code below.


So, creating a Query for field 'id' with an example value 'abc' will
return
two hits. Any ideas what I am doing wrong? Is this a bug?

Also, if you see anything I am doing stupidly or that can be
improved,
please let me know.

Thanks,
-Rob


IndexReader reader = IndexReader.open(project.search_index_path.getNativePath()); reader.delete(new Term("id", member.content_idref)); reader.close();

ISO8601Converter iso_conv = new ISO8601Converter();

try {
 IndexWriter writer = new
IndexWriter(project.search_index_path.getNativePath(), new
StandardAnalyzer(), false);
        
 File f = new


File(project.content_path.lookup(member.content_idref.concat(".xml")).getNat


ivePath());

XMLSearchHandler hdlr = new XMLSearchHandler(f);

Document doc = hdlr.getDocument();

doc.add(Field.Text("id", member.content_idref)); doc.add(Field.Text("status", status)); doc.add(Field.Text("type", target_elem.getAttributeValue("type")));

doc.add(Field.Text("creator",
target_elem.getAttributeValue("creator"))); doc.add(Field.Text("last_mod_by", member.full_name)); doc.add(Field.Text("modified",



DateField.dateToString(iso_conv.parse(target_elem.getAttributeValue("modifie


d"), new ParsePosition(0))))); doc.add(Field.Text("created",


DateField.dateToString(iso_conv.parse(target_elem.getAttributeValue("created


"), new ParsePosition(0))))); doc.add(Field.Text("label", label)); doc.add(Field.Text("keywords", keywords));
writer.addDocument(doc);


 writer.optimize();
 writer.close();

} catch (Exception e) {
 ...
}


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]




__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com

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